Game Development Reference
In-Depth Information
_pieceList.push(pieceBitmap);
}
}
return _pieceList;
}
public function cleanUp():void {
for each (var bmd:BitmapData in _pieceList) {
bmd.dispose();
}
_pieceList = null;
}
public function destroy():void {
cleanUp();
_sourceBitmap.dispose();
_imageClass = null;
}
The getImages method is, definitely, the heavy-lifter of this class.
If the list of BitmapData objects already exists (in other words, the
image has already been cut up), the function simply returns that
list again. This is to prevent destruction of still usable objects and
creation of unnecessary new objects, as BitmapData can be costly
to create and destroy repeatedly. For each rectangle on the grid, a
new BitmapData object is created in fixed dimensions and has the
pixel data from the original image copied to it. The cleanUp and
destroy functions, as mentioned earlier in the section on the inter-
face, are there to properly dispose of the references to BitmapData,
when the game is through with them. Although not particularly
crucial with only one image, if you had a game with 10, 50, or 100
images, then you would not want to keep all of them in memory at
once
re working with at any given moment.
Now, we have all the classes we need to make the game work, but
we have no measure of skill or statistics to associate with the
player
just the one you
'
s performance. From here, we switch gears to what happens
when the game is over.
'
The GameHistory and Results Classes
Although it sounds like a cool course that you
'
d take at a college,
this class contains a few pieces of data about how the player did in
a particular round of MixUp.
public class GameHistory {
public var won:Boolean;
public var time:int;
Search Nedrilad ::




Custom Search