Game Development Reference
In-Depth Information
constructor. For this reason, the entire section is listed. You should delete the previous
constructor function and replace it with all of the following code:
public function GameDemoIteration1() {
init();
}
private function init():void {
initTileSheetData();
player = new TileByTileBlitSprite(tileSheet, playerFrames, 0);
readBackGroundData();
drawLevelBackGround()
readSpriteData();
addChild(canvasBitmap);
newGame();
}
private function newGame():void {
newLevel();
}
private function newLevel():void {
restartPlayer();
addChild(player);
}
private function restartPlayer(afterDeath:Boolean=false):void {
trace("restart player");
player.visible = true;
player.currCol = playerStartCol;
player.currRow = playerStartRow;
player.x=(playerStartCol * tileWidth)+(.5*tileWidth);
player.y = (playerStartRow * tileHeight) + (.5 * tileHeight);
player.nextX = player.x;
player.nextY = player.y;
player.currentDirection = MOVE_UP;
playerStarted = true;
playerInvincible = true;
playerInvincibleCountDown = true;
playerInvincibleCount = 0;
}
You will notice that we are starting to simulate an actual game loop (new game, new level,
restarts, and so on) with some stub functions that will later interact with the framework classes.
Since there is no framework to deal with yet, we simply call the classes in order— init calls
newGame , and newGame calls newLevel .
The init function for iteration 1
The new init function is basically a copy of the contents of the previous constructor function. We
have added one line though:
player = new TileByTileBlitSprite(tileSheet, playerFrames, 0);
Search WWH ::




Custom Search