Game Development Reference
In-Depth Information
placeShips() : Puts a player's fleet on the screen
runGame() : Called by Main for the game loop
checkEnemies() : Checks to see if an enemy plane should be created
checkBonusPlane() : Checks to see if a bonus plane should be created
update() : Calculates new positions for all objects
checkCollisions() : Checks to see if objects have hit one another
addToScore() : Adds a score for hitting planes
render() : Physically places objects on the screen
checkforEndLevel() : Checks to see if level has been completed
addToScore() : Adds to the score for shots left over
cleanUpLevel() : Cleans up objects for the next level
checkforEndGame() : Checks to see if the player has lost the game.
shootListener() : Listens for mouse button click to fire a shot
mouseMoveListener() : Listens for mouse movement to update placement of crosshairs.
Updating GameFramework.as
Before we get into the core of the Flak Cannon-specific code, we need to discuss some updates
to the game framework to support the SoundManager that we created in the last chapter. These
changes are not specific to Flak Cannon, but they are specific to the game framework. We have
placed this code in this chapter to enforce the point that the sound manager, while part of the
game framework, can be used on its own. This section shows how we will integrate it into the rest
of the code.
The first thing we need to do in GameFrameWork.as is to add a variable to hold the reference to
SoundManager . This is named soundManager and will be placed in the properties definition section
of the class.
public var soundManager:SoundManager;
Note This might be a good time to download the source fcode from one of the web addresses on the
back cover of the topic. You can find the final version of GameFramework.as in
/source/class/com/efg/framework/ .
If you recall from Chapter 4, we created CustomSoundEvent , which was an event we could use
with SoundManager to tell Main.as when a game needed to play a sound. We need to add a
couple lines to a couple different functions from GameManager.as to use this event. The first
function is systemNewGame() . We need to add GameFrameWork as an EventListenter to the game
class (in this case, game is an instance of FlakCannon ). We set soundEventListener() as the
function to call when the event is dispatched.
Search WWH ::




Custom Search