Flash Game Development with Flex and Actionscript - Bitmap Animations (Page 3 of 4)

Article by Matthew Casperson (4,880 pts ) , published Nov 6, 2009

ResourceManager.as

package

{

import flash.display.*;

public final class ResourceManager

{

[Embed(source="../media/brownplane.png")]

public static var BrownPlane:Class;

public static var BrownPlaneGraphics:GraphicsResource = new GraphicsResource(new BrownPlane(), 3, 20);

[Embed(source="../media/smallgreenplane.png")]

public static var SmallGreenPlane:Class;

public static var SmallGreenPlaneGraphics:GraphicsResource = new GraphicsResource(new SmallGreenPlane(), 3, 20);

[Embed(source="../media/smallblueplane.png")]

public static var SmallBluePlane:Class;

public static var SmallBluePlaneGraphics:GraphicsResource = new GraphicsResource(new SmallBluePlane(), 3, 20);

[Embed(source="../media/smallwhiteplane.png")]

public static var SmallWhitePlane:Class;

public static var SmallWhitePlaneGraphics:GraphicsResource = new GraphicsResource(new SmallWhitePlane(), 3, 20);

[Embed(source="../media/bigexplosion.png")]

public static var BigExplosion:Class;

public static var BigExplosionGraphics:GraphicsResource = new GraphicsResource(new BigExplosion(), 7, 20);

[Embed(source="../media/smallisland.png")]

public static var SmallIsland:Class;

public static var SmallIslandGraphics:GraphicsResource = new GraphicsResource(new SmallIsland());

[Embed(source="../media/bigisland.png")]

public static var BigIsland:Class;

public static var BigIslandGraphics:GraphicsResource = new GraphicsResource(new BigIsland());

[Embed(source="../media/volcanoisland.png")]

public static var VolcanoIsland:Class;

public static var VolcanoIslandGraphics:GraphicsResource = new GraphicsResource(new VolcanoIsland());

[Embed(source="../media/twobullets.png")]

public static var TwoBullets:Class;

public static var TwoBulletsGraphics:GraphicsResource = new GraphicsResource(new TwoBullets());

[Embed(source="../media/cloud.png")]

public static var Cloud:Class;

public static var CloudGraphics:GraphicsResource = new GraphicsResource(new Cloud());

}

}

As you can see all we have done is to add values for frames and fps in the GraphicsResource constructor for those images that will now be animations.

The final step is to modify the game elements that should now be animated to extend the AnimatedGameObject class instead of GameObject, and to create some explosions when we destroy a plane.

Both the Player and Enemy classes will be animated, and both will create an explosion when they are destroyed. The code changes are the same for both classes, so I will show only the new Enemy class. You can download the source code at the end of the article to see the changes made to the Player class.

Showing page 3 of 4
Subscribe to Web Development
RSS
Get free weekly updates, directly to your inbox.
Browse Web Development