A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: controlling player fire in space invaders game

Hybrid View

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

    controlling player fire in space invaders game

    Hi all,

    I'm working through an online tutorial on Space Invaders in Flash MX 2004.

    I've got the player craft under mouse control. What I don't like about the game is that you can fire as rapidly as you wan't, though the number of bullets is limited. You can change this limit in the variable - I would rather have it though that you can only fire according to a certain interval - a bullet every second, or half second for example.

    Here is the code:

    // when the mouse cliks
    onClipEvent(mouseDown)
    {
    // duplicate the bullet mc
    _root.bullet.duplicateMovieClip("bullet"+bulletNum ,bulletNum);
    // set the coords to the mouse clik
    eval("_root.bullet" + bulletNum)._x = this._x;
    eval("_root.bullet" + bulletNum)._y = this._y;
    // increment the bullet number
    bulletNum++;
    // if more than 50 bullets , start again at 0
    if(bulletNum>50)
    bulletNum = 0;
    }

    Anyone have any code that could be used for this, or ideas on how I could modify the above?

    regards,

    g

  2. #2
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Howdy, you might be able to use a variable. You cold have it increase like your bulletNum variable and then after it hits a certain number say 5 it would stop shooting and after you let go of the button it goes back to 0.

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