I have just read the tut on the shooting aspect of games and i tried it for myself. I altered it so that you shoot on the x axis and you shoot when the space button is pressed.
My question is, how do you make the bullets shoot when the space button is releases? And or can make the bullet shoot at an interval of one second or so when the space is pressed… The bullets for me are shooting at a continuous streem and that may be a too great advantage for a user…
Or, create a function and use setInterval() to call it…
function shootBullet()
{
// your shooting tween or animation goes here //
}
shootInterval = setInterval(shootBullet, 1000);
// this runs shootBullet() function in every 1 second...
Chech out the Flash manual or search the forum for more information on setInterval()/clearInterval() functions…
i tried your way first CyanBlue but it doesn’t really work. when the space bar is pressed, it takes one second before the bullets start shooting in a stream rather than shooting a bullet everysecond. Maybe I’m doing something wrong… where you said to place the tween or animation i put the AS where it tells the bullet to shoot…:q:
And playamarz, I don’t really understand how to set up a timer… If you can slowly walk me through it, that would be really helpful. Thanks again…(-:
Yup… I know what that is… It takes that much of time to start one cycle with setInterval()… Don’t know why that is behaving like that… I just call the function one time and then do the setInterval afterwards…