Developing a space shooter game [ October 07, 2004 ] by Richard Nias aka Crashlanding
In this collection of tutorials, the author explains how to create a basic shooter game, considering all its different aspects: movement, shooting, enemies, sound, etc.
At the moment, the game is easy because you just hold down the spacebar and millions of bullets come out all at once, making it possible to block enemies off completely. Look at this screenshot:
In this tutorial we are going to stop this and add a bit more animation into the game.
So first, let's make a shooting animation for the hero. Put stop(); on the first frame. We'll add some code to the last frame later.
Now go to where all your code is kept and add this to the top.
var fire = false;
Now change the moveHero function:
if (fire == false)
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.
fire = true;
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:
_root.fire = false;
So when the animation has ended, hero has finished shooting and you can shoot again. Simple!
If you have any problems e-mail me at firstname.lastname@example.org and I will answer as well as I can. If you want to download the .fla click here.
Richard Nias aka Crashlanding
South-east London, UK
Had Flash for 1 1/4 years now. I learnt from the help files before finding gotoandplay and flashkit, getting me intrested in games.