Game pause problems with character movement
I have created a pause scene in my game which works great, but...
But my character is controlled by touching the screen so that means when the game is paused the character also receives a touch event. And when the game is unpaused the same thing happens.
So to try and solve this with logic I created a boolean attribute game.isGamePaused to turn off the character controls when the game is paused. I even put a timer in there to be safe. But when the timer finishes I still get a hit on the screen which I thought could be from the first touch.
To test that I replaced the touch event to end pause, with a the keypress P. And I am still getting the hit on the screen - but my logic game.isGamePaused is working to disable further touches or perhaps the game is just paused.
So, I have figured out that when the pause button is pressed the player also gets a touch event. That touch event waits until the game is unpaused and then fires.
Do I have to put a button over my screen but not near the pause button to make this work properly?
But my character is controlled by touching the screen so that means when the game is paused the character also receives a touch event. And when the game is unpaused the same thing happens.
So to try and solve this with logic I created a boolean attribute game.isGamePaused to turn off the character controls when the game is paused. I even put a timer in there to be safe. But when the timer finishes I still get a hit on the screen which I thought could be from the first touch.
To test that I replaced the touch event to end pause, with a the keypress P. And I am still getting the hit on the screen - but my logic game.isGamePaused is working to disable further touches or perhaps the game is just paused.
So, I have figured out that when the pause button is pressed the player also gets a touch event. That touch event waits until the game is unpaused and then fires.
Do I have to put a button over my screen but not near the pause button to make this work properly?
Comments
I have tried resetting touch and mouse counts to zero but that has no effect.
I just created a quick test and I didn't have the problem you're describing. In the test, click on the lower left white square to pause the game. Click on the upper right square to unpause. If you have the log debugger window open, you should see "mouse down" when you click to pause but not when you click to unpause.