Sign in to follow this  
Introvert Studios

Pausing physics?

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'!

Share this post

Link to post
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    }}

Share this post

Link to post
Share on other sites

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?

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.