Game Development Reference
In-Depth Information
Again, the only function we will override in GameFrameWork is init() , and even then, the
override includes mostly specific customizations for Flak Cannon. The rest of the game
framework remains untouched. The first change is that we pass the width and height (600
400) into the instance of FlakCannon . FlakCannon will use these values to set boundaries for
objects in the game.
The rest of the changes highlighted below are size, positioning, and textual updates to support
Flak Cannon specifically. The game is 600
400 pixels and requires the scoreboard to keep track
of Score, Shots, and Ships fields. We use the text Flak Cannon on the title screen with buttons that
say Go! and Shoot The Enemy Planes! On the instructions screen, there's a Play! button, and on the
end screen, a Game Over label with a Play Again button.
override public function init():void {
game = new FlakCannon(600,400);
setApplicationBackGround(600,400,false, 0x0042AD);
scoreBoard = new ScoreBoard();
addChild(scoreBoard);
scoreBoardTextFormat= new TextFormat("_sans", "11", "0xffffff", "true");
scoreBoard.createTextElement(SCORE_BOARD_SCORE, new
SideBySideScoreElement(80, 5, 15, "Score",scoreBoardTextFormat, 25, "0",
scoreBoardTextFormat));
scoreBoard.createTextElement(SCORE_BOARD_SHOTS, new
SideBySideScoreElement(240, 5, 10, "Shots",scoreBoardTextFormat, 40, "0",
scoreBoardTextFormat));
scoreBoard.createTextElement(SCORE_BOARD_SHIPS, new
SideBySideScoreElement(400, 5, 10, "Ships",scoreBoardTextFormat, 50, "0",
scoreBoardTextFormat));
screenTextFormat = new TextFormat("_sans", "14", "0xffffff", "true");
screenButtonFormat = new TextFormat("_sans", "11", "0x000000", "true");
titleScreen = new BasicScreen(FrameWorkStates.STATE_SYSTEM_TITLE, 600,400,
false, 0x0042AD);
titleScreen.createDisplayText("Flak Cannon",250,new Point(255,100),
screenTextFormat);
titleScreen.createOkButton("Go!",new Point(250,250),100,20,
screenButtonFormat,0xFFFFFF,0xFF0000,2);
instructionsScreen = new BasicScreen(FrameWorkStates.STATE_SYSTEM_INSTRUCTIONS,
600,400, false, 0x0042AD);
instructionsScreen.createDisplayText("Shoot The Enemy Planes!",300,
new Point(210,100),screenTextFormat);
instructionsScreen.createOkButton("Play",new Point(250,250),100,20,
screenButtonFormat,0xFFFFFF,0xFF0000,2);
gameOverScreen = new BasicScreen(FrameWorkStates.STATE_SYSTEM_GAME_OVER,
600,400, false, 0x0042AD);
gameOverScreen.createDisplayText("Game Over",300,new Point(250,100),
screenTextFormat);
gameOverScreen.createOkButton("Play Again", new Point(225,250),150,20,
screenButtonFormat,0xFFFFFF,0xFF0000,2);
levelInText = "Level ";
levelInScreen = new BasicScreen(FrameWorkStates.STATE_SYSTEM_GAME_OVER,
600,400, false, 0x0042AD);
Search WWH ::




Custom Search