Creating a shooting game using flash 8 – Lesson 3

Lesson 3 – Making a score board and stop the constant firing.

(Step 1) Draw some dynamic text onto the stage where the main game is.

(Step 2) Add the above action script to the main actions keyframe.

This is just to set the original value of score to 0. But where do we put the code to add scores?

the above script is only a section of the entire action script.

(Step 3) Add the above code to the end of the movie clip for the enemy.

If we put it in the hitTest bit of the bullet code, then the score will keep going up and up untill the death animation is finished. The best thing to do is to put the code at the end of the death animation. So, in your enemy movieclip on the last frame put:


(Step 4) Click on control and test movie to see your score board working.


(Step 5) At the moment, the game is too easy to win. When you hold down space bar, you just keep on firing. We need to make some changes to make the game a little harder.

To do this we need to change various parts of the code.

The above image shows the bullets constantly coming out.

(Step 6) Double click on the hero movie click. We are going to make this look like it is firing.

(Step 7) Insert a keyframe on about 15. Add a stop to the beginning.

(Step 8) Insert a new layer.

(Step 9) It’s on the new layer, layer 2, that we are going to add a small animation to look like firing is happening.

(Step10) Create a simple animation to make it look like the hero is firing. For this I have just used 3 colours.

(Step11) Add the above code to the main actions frame.

Your main code should now look similar to the above. This is just part of the main code.

(Step12) You need to change your move hero function with the above code.

So, if fire=false, it means you're not shooting so you can shoot. If fire=true, you're already shooting so you can't shoot again. So, we need to change fire to true when you start shooting. Put this in the fireBullets function.

(Step13) Add this code to the fireBullets function

This plays the hero firing animation and sets fire to true. But if you left it at that, you would only have one shot because fire would stay true. So go to the end of the hero's animation and put:


The above is how your entire code should look at the moment.

(Step14) Add the above code to the end of the hero animation. You will need to go into the hero movie clip to do this.

(Step15) Test your movie and you will see that you can now only fire one bullet at a time.