Game Development Reference
In-Depth Information
sound.play();
enemies.splice(i,1);
removeChild(tempEnemy);
}
}
}
public function testForEnd():void {
if (chances>= 5) {
gameState = STATE_END_GAME;
} else if(score > level*20) {
level++;
levelText.text = level.toString();
}
}
public function endGame():void {
for(var i:int = 0; i < enemies.length; i++) {
removeChild(enemies[i]);
}
enemies =[];
player.stopDrag();
}
}
}
OK, we fibbed a bit. There is a lot of new code. You didn't think an AS3 game would be that easy,
did you? In reality, this example is not much more complicated than the first. We are still calling a
game loop on a timer and waiting for user input. We have just added a few more elements to
make it into a bona fide Flash game.
Balloon Saw gameplay
Why don't you take this code and compile it in your chosen development tool to see what it looks
like before we continue? If you are using the Flash IDE, recall that you can test this game as
follows:
1.
Save the code as Game.as .
2.
Create a new Flash AS3 .fla document in the IDE, and save it in the same directory
as Game.as .
3.
Set the Document property in the Flash IDE for your new .fla document to Game.
4.
In the Modify Document menu, set the dimensions for the game to 550
400.
5.
Test the game with Ctrl/Cmd+Enter or by using the Control Test Movie menu option.
Figure 1-6 shows the game screen as you should see it.
Note, if you interested in making games without the Flash IDE, that we will start that process in
Chapter 2.
Search WWH ::




Custom Search