A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Don't like auto-fire :(

Hybrid View

  1. #1
    Junior Member
    Join Date
    May 2005
    Posts
    6

    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!

  2. #2
    Noor._alpha = 0 ! nooor83's Avatar
    Join Date
    Aug 2005
    Posts
    252
    use
    on (keyPress "your key")
    {
    run the shooting function ;
    }

    use return; whenever u want to exit a function..

    Regards,

    Noor

  3. #3
    Junior Member
    Join Date
    May 2005
    Posts
    6
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center