Two shots fired. Only on first time firing...this is weird!
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...
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
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...
Not sure if that even makes sense but I know what's going on now! Thanks guy! You're the best!