A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: breakout question

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    1

    breakout question

    I'm stuck. I'm creating a breakout type game and I am trying to make it where when your paddle is in a certain frame you can shoot fireballs upward. I got it all working fine but, if you hold the shoot button down (space) it just duplicates infinity amount of fireballs. =/

    Can anyone please help me?
    Attached Files Attached Files

  2. #2
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    You need to use a counter to wait a bit after shooting. Heres some sample code to give the idea
    Code:
    var can_shoot:Boolean = true;
    
    on Keypress... // whatever, I forgot as2
    {
      if(can_shoot==true)
      {
           //shooting code
           // .....
           can_shoot = false;
           setInterval(resetShooting,20) //I forgot if this duration was seconds or miliseconds
      } 
    }
    
    function resetShooting()
    {
       can_shoot = true;
    }
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

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