Pause Game

Hello all,

I have a question concerning implementing a pause game function. I have droplets of water that are falling from the ceiling, and when the pause button is tapped I would like them to stop moving, and when tapped again they would continue to fall from their last position. I have gotten it to where they stop moving when the pause button is tapped, however it seems they continue updating without redrawing, so it appears they jump after the pause button is tapped again.

My question is, how would I stop the droplets of water from updating in the background while the pause screen is up, and then continue to update after gameplay is resumed?

Any help would be appreciated.

Thanks

What you want is a state machine, with one state being running, and the other state being paused. You may want to search the forums for state machine. Also, there is some info about it on @Reefwing’s tutorial site.

@Vega I’m actually using a state machine as well, with one state playing and the other paused. When the pause button is tapped I switch the game state to paused, and the droplet’s position should only be updated when the game state is playing. But for some reason in the background it updates the position. Everything else runs fine with the state machine, however, which is why this confuses me even more.

Can you post your code? :slight_smile: I would love to check it out! :smiley:

Perhaps you are using the physics engine for your rain. If so, you need to pause physics using

physics.pause()

Then, when you want the rain to start moving again you use:

physics.resume()

Hope that helps.

@Vega That did it, thanks. I hadn’t realized that I was actually using physics.body to define and update the position. Thanks again