Game Development Reference
In-Depth Information
BitmapData objects, we simply update the images we
ve already
created. Because these objects are associated with the Bitmaps
inside of the game pieces, those Bitmaps will automatically be
updated when the pixel data inside their BitmapData changes.
'
public function cleanUp():void {
for each (var bmd:BitmapData in _pieceList) {
bmd.dispose();
}
removeEventListener(Event.ENTER_FRAME, updateImages);
_pieceList = null;
}
public function destroy():void {
cleanUp();
_sourceBitmap.dispose();
_video = null;
_camera = null;
}
Finally, only minor changes are needed to the cleanUp and
destroy methods. The frame loop must be removed, and the video
and camera objects nulled. Back in the MixUp class, you only need
to change one line to change the game from using a static image
to using this new source. On the game.init line in the setupGame
method, change the line to look like this:
game.init(new SourceImageCamera(640, 480, 24), 3, 4);
Thegamewillnowusealivefeedinalltherectangles,which
makes the game even more interesting if there is much motion in
the background behind you. You can apply these same techniques
to create new SourceImage classes that pull in imagery.
Review
In this chapter, we took a simple game from basic concept and rule
set to completion using interfaces to keep it modular. In the next
chapter, we will apply these concepts further on a much larger,
more complicated game.
Search Nedrilad ::




Custom Search