Game Development Reference
In-Depth Information
private var exhaustAnimationList:Array = [];
private var lastExhaustTime:int = 0;
private var exhaustDelay:int = 100+((obstacleSpeedMax * 10) - (10 * obstacleSpeed));
//score
public var score:int = 0;
private var lastScoreEvent:int = 0;
private var scoreDelay:int = 1000;
private var gameOver:Boolean = false;
public function TunnelPanic() {
init();
}
// end class
// end package
The init functions follow. The init functions for Tunnel Panic are the one-time setup functions
for the player's ship, the drawing of the play field, the creation of the obstacle and exhaust pools
and the creation and initialization of the canvas for the exhaust particles.
Note: Please make sure to add these new functions inside the class, after the constructor.
public function init():void {
this.focusRect = false;
createPlayerShip();
createPlayfield();
createObstaclePool();
createExhaustPool();
setUpCanvas();
canvasBitmap.y = 20;
addChild(canvasBitmap);
addChild(playfieldSprite);
}
private function createPlayerShip():void {
//draw vector ship and place it into a Sprite instance
playerShape.graphics.clear();
playerShape.graphics.lineStyle(2, 0xff00ff);
playerShape.graphics.moveTo(15, 7);
playerShape.graphics.lineTo(7, 24);
playerShape.graphics.lineTo(15, 19);
playerShape.graphics.moveTo(16, 19);
playerShape.graphics.lineTo(24, 24);
playerShape.graphics.lineTo(16, 7);
playerShape.x = -16;
playerShape.y = -16;
playerSprite.addChild(playerShape);
}
private function createPlayfield():void {
Search WWH ::




Custom Search