-
Don't like auto-fire :(
Basically, I have just made a scrolling shooting game using a tut on here.
However, I want to kill the function that makes the 'gun' autofire when the key is held down. Is there a way to make it 'single shot' so the key has to be pressed multiple times (The game is too easy if you just hold down ctrl and sweep the screen)
Thanks for helping a noobie!
-
use
on (keyPress "your key")
{
run the shooting function ;
}
use return; whenever u want to exit a function..
Regards,
Noor
-
if (Key.isDown(Key.CONTROL)) { laserCounter++;
_root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
_root["laser"+laserCounter]._visible=true;
}
that is the code I have at the moment. Am I right in guessing I should have:
on (keyPress "CONTROL")
{ laserCounter++;
_root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
_root["laser"+laserCounter]._visible=true;
}
However, I cannot have this 'on' function as it is nested within another 'on' handler.
This is what I tried but does not work:
onClipEvent(load){
moveSpeed=15;
_root.laser._visible=false;
laserCounter=1;
scrollx=_root.mainGround.ground._width/3;
scrollStart=false;
}
onClipEvent (enterFrame) {
on (keyPress"CONTROL") { laserCounter++;
_root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
_root["laser"+laserCounter]._visible=true;
}
if (Key.isDown(Key.RIGHT)) {
if (this._x<scrollx){
this._x+=moveSpeed;
} else {
scrollStart=true;
}
} else if (Key.isDown(Key.LEFT)) {
this._x-=moveSpeed;
}
if (Key.isDown(Key.DOWN)) {
this._y+=moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y-=moveSpeed;
}
}
onClipEvent (keyUp) {
if (Key.getCode() == Key.RIGHT) {
scrollStart=false;
}
}
Thank you for your time.