A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: bullet rate[simple]

Threaded View

  1. #1
    Flash Incompetent ChaseNYC's Avatar
    Join Date
    Jun 2002
    Location
    new york city
    Posts
    693

    [RESOLVED] bullet rate

    well, I presume this is a simple question, I have scanned the forums a bit and cannot seem to come up with any conclusions to my problem. I am making space invaders style game and I am using one of the tutorials from flashkit which uses the following code for shooting:

    Code:
    onClipEvent(load){
     _root.laser._visible=false;
     laserCounter=1;
    }
    
    if (Key.isDown(Key.SPACE)) {
    		
    		laserCounter++;
    		_root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
    		_root["laser"+laserCounter]._visible=true;
    		trace(laserCounter);
    	} 
    
    //this is in the bullet/laser action
    
    onClipEvent (load) {
    
      laserMoveSpeed=20;
      this._y=_root.spaceship._y - ((_root.spaceship._height / 2) + (this._height)); 
      this._x=_root.spaceship._x;
    
    }
    
    onClipEvent (enterFrame) {
    
      this._y-=laserMoveSpeed;
      if (this._y>600){
        this.removeMovieClip();
      }
    
    }
    now, the code works fine for what it is supposed to do; however, my problem lies in the fact that I do not want it to be the case that if the user holds down the spacebar it will shoot the bullet at the maximum speed, I would like to figure out some way that(these times are not exact but just examples) if the spacebar is held down it will shoot a bullet every 2 seconds; and if the user taps the spacebar they can shoot up to one bullet every second. Hopefully this makes sense, I apologize greatly if this question is explained somewhere else but I did look around and could not find any examples.

    Thanks in advance,

    ChaseNYC
    Last edited by ChaseNYC; 06-26-2006 at 08:03 AM.
    mmm signature

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