Jump to content

Pausing physics?


Introvert Studios
 Share

Recommended Posts

Using the Phaser states, I would like to be able to pause the game while retaining the ability to click on

other buttons in that state.

 

At the moment, when the game is paused it seems the engine takes over and prevents input to other buttons and such.

An alternative solution for me, would be to just pause physics updates, but can't find anything that lets me do this :(

 

(The end result will be a pause screen that I can input to, before un-pausing again).

 

- Thanks'!

Link to comment
Share on other sites

Quick fix is to just wrap all of your update calculations in an if-statement and create a custom paused variable that you set every time the paused button is pressed.  

 

I believe the more elegant solution is to use game states, and change states every time the game is paused rather than setting game.paused to true.  

function update() {    if (!gameIsPaused) { //custom paused variable        //All of your update calculations    }}
Link to comment
Share on other sites

  • 2 months later...

Hi Introvert,

 

I'm having the same problem too. I use a state machine to toggle "screens" in my game. So the "Game screen" will be running, then i pause it and change it to "menu screen". When i return to "game screen", the positions of all my physics bodies jump to a position in time as if the engine was still calculating velocities. 

 

Maybe I can reset the game time to right when I paused? Or is it possible to pause all of the bodies velocities? What was your solution?

Link to comment
Share on other sites

  • 2 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...