-
1 Attachment(s)
breakout question
I'm stuck. I'm creating a breakout type game and I am trying to make it where when your paddle is in a certain frame you can shoot fireballs upward. I got it all working fine but, if you hold the shoot button down (space) it just duplicates infinity amount of fireballs. =/
Can anyone please help me?
-
You need to use a counter to wait a bit after shooting. Heres some sample code to give the idea
Code:
var can_shoot:Boolean = true;
on Keypress... // whatever, I forgot as2
{
if(can_shoot==true)
{
//shooting code
// .....
can_shoot = false;
setInterval(resetShooting,20) //I forgot if this duration was seconds or miliseconds
}
}
function resetShooting()
{
can_shoot = true;
}