Great, now we want to set up a game over message, that is displayed if the players spaceship collides with an enemy.
You may want to do an animation sequence for the end of the game, but to keep this tutorial as simple as possible our end sequence will be one frame with the message Game Over and the final score.
Lets do it
the actions window if its still open.
On the main timeline add an extra frame to the end of every layer, so you will now have a 3 frame movie. Now, insert a blank keyframe (Insert > Blank key frame) on frame 3 of the enemy, laser, spaceship and control layers (as shown on the right)
The main timeline stops on frame 2 while the game is playing. When the game is over it will move to frame 3. We inserted blank keyframes on the laser, spaceship and enemy layers because we don't want these movieclip still visible at the end of the game.
Select the blank keyframe on frame 3 of the control layer and in the frame panel give the frame the label gameOver (as shown on the right).
Previously we set up the code for the main timeline to goto a frame labelled gameOver when a collision between the player and enemy is detected. We have now added in that label.
Still on the main timeline add in a new layer called game
over and insert a blank keyframe on the third frame of this new layer (select
frame 3 of the layer and Insert > Blank Keyframe).
Now, at this new keyframe add some text on the stage saying game over. It doesn't matter what font or size or colour - just pick something you like. Move the game over message to the middle of the stage.
OK, we now have the core game built. Give it a test!
Having tested the game you will probably have noticed two key things we need to improve.
1. We need a way to restart the game when its over.
2. At the moment you can fire lasers continuously which doesn't make the game very challenging. What we want to do is limit the amount of laser fire on the screen at any one time. This type of limited fire is common in arcade games and means that the player has to think before they fire.
We will make both of these improvements in the next step
|» Level Intermediate|
Rating: 9 Votes: 517
|No details available.|
|Download the files used in this tutorial.|
|Download (416 kb)|
|More help? Search our boards for quick answers!|