How to pause the game?

Hi,

I want to pause the game in certain situations, I have control over all of my game mechanics and can stop them temporarily with a boolean flag but I rather to like “freeze” the game and stop moving objects as I don’t have control over them in my code.

I was thinking of pausing physic engine but since physic bugs are very frustrating and odd and I’m out of time, I rather ask you kind people.

I very much rather to freeze my physic objects but be able to drag them around and when I unpause, they would resume their motion.

Thanks.

* Bump *

If you want to avoid physics.pause(), then it sounds like you need to loop through each physics object, get their linear and angular velocities, save the values in custom properties of the object, then set the linear and angular velocities to zero.  When you unpause, loop through all the objects again and set the linear and angular velocities to your saved values.

But have you tried physics.pause()?  I haven’t used it, but I’m not aware of any bugs with it either.  It’s worth a try, since that sounds like a simple solution.

  • Andrew

Thanks man, I do like the ease of physics.pause but the bad thing is, all my sprite animations will still be playing because they are unrelated to physic.

Well it sounds like, no matter what, you’ll have to deal with the three things separately: pausing the movement of physical objects, pausing sprite animations, and pausing transitions (if you have any).  There’s no automatic way to do all of these things at once.  But for the physics part, I don’t know why you wouldn’t use physics.pause().

  • Andrew

Thanks Andrew.

* Bump *

If you want to avoid physics.pause(), then it sounds like you need to loop through each physics object, get their linear and angular velocities, save the values in custom properties of the object, then set the linear and angular velocities to zero.  When you unpause, loop through all the objects again and set the linear and angular velocities to your saved values.

But have you tried physics.pause()?  I haven’t used it, but I’m not aware of any bugs with it either.  It’s worth a try, since that sounds like a simple solution.

  • Andrew

Thanks man, I do like the ease of physics.pause but the bad thing is, all my sprite animations will still be playing because they are unrelated to physic.

Well it sounds like, no matter what, you’ll have to deal with the three things separately: pausing the movement of physical objects, pausing sprite animations, and pausing transitions (if you have any).  There’s no automatic way to do all of these things at once.  But for the physics part, I don’t know why you wouldn’t use physics.pause().

  • Andrew

Thanks Andrew.