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…
you can set a script to detect whether or not the spacebar is pressed and then set an if statement to the fire function when the spacebar isn’t detected as pressed
there was a question i had similar to that i’ll see if i can find it. but there is nothing like on(keyrelease) i think there should be =)
Thanks for the info shuga… Another question, is it possible to add a timer or something so that a bullet is shot only once a second… that would be really useful… Thanks
do i know exactly how to do it off the top of my head? no
i know there is a way to do it with just actionscript but i’m still learning the language myself so the only way that comes to mind is to put an empty movieclip on the stage that is 20 frames long (provided your movie is set to 20 fps) then put an if statement before your “fire” function that says
if (_root.emptyMC._currentframe=20){
_root.ship.fire;
}
then in your fire function tell it to _root.emptyMC.gotoAndPlay(1)
ofcourse you’ll have a stop at frame 20 which will be the end of one second. so after one second the currentFrame will be equal to 20 and the fire will be enabled.
i’m sure there is a way to do that with just actionscript. but i’m not at work … i’m on a laptop out in the mountains so i don’t have flash with me right now to try it out. i will check on it tomorrow when i return to work if you haven’t figured it out by then.