Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Pause Game

edited July 2012 in Questions Posts: 18

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

Comments

  • Posts: 179

    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.

  • Posts: 18

    @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.

  • Posts: 371

    Can you post your code? :) I would love to check it out! :D

  • Posts: 179

    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.

  • Posts: 18

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

Sign In or Register to comment.