Game Development Reference
In-Depth Information
The application background and game Sprite location
Now we will set the background color for the application and position the game Sprite on the
screen.
1.
In the variable definition section, we changed the application size to 640
500 pixels.
We have added 20 pixels at the top of the screen for a scoreboard.
setApplicationBackGround(640, 500, false, 0x000000);
2.
We have moved the game instance down to a y position of 20 to accommodate the 20-
pixel scoreboard at the top of the game screen.
game.y = 20;
The ScoreBoard
We added four elements to our ScoreBoard to handle the SCORE , AMMO , TANKS , and HEALTH values
that we want to display to the user. The constants were added to the variable definition section
and the createTextElement calls were added to the init function.
Here are the four new elements we will be adding:
Score: The player's score
Ammo: The ammunition the player has left (starts with 50 on a new tank)
Health: The health points left for the player tank (starts with 5)
Tanks: The number of tanks the player has left
The Screens
We added text, locations, and buttons (if necessary) to the four screens ( titleScreen ,
instructionsScreen , gameOverScreen , and levelInScreen ).
The Sounds
We added constants for all of our sounds to the variable definition section and addSound
function calls to the init function. Notice that we have added the Library class name to the
front of all of the sounds in the Flex SDK code. This is an important difference between the
Flash IDE and Flex SDK versions of the code, and we will explore this in detail in the next
section on integrating sound.
The New Function Overrides for the Sounds
We have two very new functions that are overrides of functions in the GameFrameWork.as file. The
systemTitle and systemNewGame functions are now set up to handle playing and stopping the
SOUND_MUSIC sound. This is done by first making a SoundManager class function call to playSound
or stopSound and then calling the Super version of each function in the GameFrameWork.as .
Search WWH ::




Custom Search