Game Development Reference
In-Depth Information
And this one is for the Flex SDK (using Flash Develop):
/source/projects/notanks/flexSDK/src/com/efg/games/notanks/GameDemoIteration1.as
Changing the class name for iteration 1
We have a new file name for the game demonstration, so now we will need to change the class
name to match. We will also need to change the name of the constructor function as follows.
First, we will change the new class name.
public class GameDemoIteration1 extends Sprite
{
And then, we will change the constructor.
public function GameDemoIteration1() {
Adding the new framework classes to the import section
Here are the class imports needed to add the Framework functionality to this iteration:
// added iteration #1
import com.efg.framework.BlitSprite;
import com.efg.framework.TileByTileBlitSprite;
// end added iteration #1
Defining the iteration 1 variables
Add these variables to the variable definition section of the existing GameDemo.as file:
//movement specific variables added in iteration #1
public static const MOVE_UP:int = 0;
public static const MOVE_DOWN:int = 1;
public static const MOVE_LEFT:int = 2;
public static const MOVE_RIGHT:int = 3;
public static const MOVE_STOP:int = 4;
//*** added iteration #1
//player specific variables
private var player:TileByTileBlitSprite;
private var playerStartRow:int;
private var playerStartCol:int;
private var playerStarted:Boolean = false;
private var playerInvincible:Boolean = true;
private var playerInvincibleCountDown:Boolean = true;
private var playerInvincibleWait:int = 100;
private var playerInvincibleCount:int = 0;
//*** end added iteration #1
Some of these variables, such as the ones controlling the invincibility of the player on restarts, will
not be used yet, but they will come into play very soon.
Next, we will add some code in the constructor and create a few new functions that will be used
later to handle interactions with the Main.as and framework classes. You will notice that we have
moved everything from the constructor to a new init function and added a line to call init in the
Search WWH ::




Custom Search