controlling player fire in space invaders game
Hi all,
I'm working through an online tutorial on Space Invaders in Flash MX 2004.
I've got the player craft under mouse control. What I don't like about the game is that you can fire as rapidly as you wan't, though the number of bullets is limited. You can change this limit in the variable - I would rather have it though that you can only fire according to a certain interval - a bullet every second, or half second for example.
Here is the code:
// when the mouse cliks
onClipEvent(mouseDown)
{
// duplicate the bullet mc
_root.bullet.duplicateMovieClip("bullet"+bulletNum ,bulletNum);
// set the coords to the mouse clik
eval("_root.bullet" + bulletNum)._x = this._x;
eval("_root.bullet" + bulletNum)._y = this._y;
// increment the bullet number
bulletNum++;
// if more than 50 bullets , start again at 0
if(bulletNum>50)
bulletNum = 0;
}
Anyone have any code that could be used for this, or ideas on how I could modify the above?
regards,
g