Game Development Reference
In-Depth Information
bitmaps needed to run through the animation. Again, notice the different code for Flex and Flash.
We then call setNextImage() to get the BitmapData for the current image, set frameCounter to 0 to
start the animation timing, and set finished to false so that FlakCannon will not instantly remove it
from the screen.
public function init():void
{
image = new Bitmap();
addChild(image);
//***** Flex *****
/*images = [new Exp1Gif().bitmapData,
new Exp2Gif().bitmapData,
new Exp3Gif().bitmapData,
new Exp4Gif().bitmapData,
new Exp5Gif().bitmapData,
new Exp6Gif().bitmapData,
new Exp7Gif().bitmapData
];
*/
//***** Flash *****
images = [new Exp1Gif(32,32),
new Exp2Gif(0,0),
new Exp3Gif(0,0),
new Exp4Gif(0,0),
new Exp5Gif(0,0),
new Exp6Gif(0,0),
new Exp7Gif(0,0)
];
setNextImage();
frameCounter=0;
finished=false;
}
setNextImage() increments the currentImageIndex counter and then checks to see if we have
reached the end of the animation. If we have, we set finished to true . If not, we set
image.bitMapData to the image at index = currebtImageIndex in the images array.
public function setNextImage():void {
currentImageIndex++;
if (currentImageIndex > images.length-1) {
finished = true;
} else {
image.bitmapData = images[currentImageIndex];
}
}
The update() function does not need to move anything. When it is called by FlakCannon , it simply
updates the frameCounter . The interesting stuff will happen in render() .
Search WWH ::




Custom Search