Two shots fired. Only on first time firing...this is weird!

DrGlickertDrGlickert Member Posts: 1,135
edited November -1 in Working with GS (Mac)
I don't even know where to begin to explain my problem. I have LOTS of code and LOTS of attributes working at one time in my game.

I have a cannon that fires a ball at where the player touches. The ball flies around and if it doesn't hit anything then the ball is destroyed after a few seconds (it's on a timer). The player can only fire one ball at a time.

When the level starts I tap the screen and the cannon shoots. If the ball doesn't hit anything and the ball-timer expires for some WEIRD reason the cannon will automatically fire a second shot. Each subsequent shot only fires 1 shot, never fires more than once. I don't want the cannon to fire automatically without input from the user. What would make it so that the code works perfectly for every shot after the first one? I don't understand!! This is weird.

I would write out all of my code, but like I said, there is a LOT of it and I don't even know where to begin to explain everything going on other than the cannon/ball/firing mechanism...

Comments

  • DrGlickertDrGlickert Member Posts: 1,135
    So I used your template on how to select overlapping actors from GS-Helper. So the background is "My Number = 1," the pause button and restart level button are "My Number = 2 and 3" respectively.

    So when the player touches the background actor and game.whatActor = self.myNumber then the background changes the following Game.Attributes; game.TargetX to mouse.position.X, TargetY to mouse.position.Y, and game.OkayToShoot to true.

    The cannon has a rule that when game.OkayToShoot is = true and game.NumberOfBalls is = 0 then the cannon rotates to the position, then fires a shot. Also, the touch must be >= 70.

    Not really sure why after shooting the first shot, it'll fire again. But all shots after that fire normally...
  • DrGlickertDrGlickert Member Posts: 1,135
    TSB! You're the man! It actually wasn't the OkayToShoot or NumberOfBalls it was that I had an actor that explained the game to the player that was making the background behind it register as a touch.

    Not sure if that even makes sense but I know what's going on now! Thanks guy! You're the best!
Sign In or Register to comment.