Game Development Reference
In-Depth Information
Create the GameDemo.as class
Create a new ActionScript class file called GameDemo.as . For the rest of this chapter, you will want
to set this class as the document class of the notanks.fla file if you are using the Flash IDE and
the always-compile class if you are using the Flex SDK and Flash Develop. For any other
development tools, follow the documentation provided for that environment, to set a base, main,
or document class for your project.
Here's the folder structure for the Flash IDE:
/source/projects/notanks/flashIDE/com/efg/games/notanks/GameDemo.as
And this one is for the Flex SDK (using Flash Develop):
/source/projects/notanks/flexSDK/src/com/efg/games/notanks/GameDemo.as
Here is the first iteration of the entire GameDemo.as class. We will add to this class in following
sections. Type the following code into the file and save it; we will discuss the code in the next
section:
package com.efg.games.notanks
{
import flash.display.Sprite;
/**
* ...
* @author Jeff Fulton
*/
public class GameDemo extends Sprite{
public static const TILE_WALL:int = 0;
public static const TILE_MOVE:int = 1;
public static const SPRITE_PLAYER:int = 2;
public static const SPRITE_GOAL:int = 3;
public static const SPRITE_AMMO:int = 4;
public static const SPRITE_ENEMY:int = 5;
public static const SPRITE_EXPLODE:int = 6;
public static const SPRITE_MISSILE:int = 7;
public static const SPRITE_LIVES:int = 8;
private var playerFrames:Array;
private var enemyFrames:Array;
private var explodeFrames:Array;
private var tileSheetData:Array;
private var missileTiles:Array=[];
private var explodeSmallTiles:Array;
private var explodeLargeTiles:Array;
private var ammoFrame:int;
private var livesFrame:int;
private var goalFrame:int;
public function GameDemo() {
initTileSheetData();
Search WWH ::




Custom Search