In my game, when I pause the game using mEngine.stop() it works perfectly but when I press resume button that has code mEngine.start() it provide some movement to the physics body. So the created body does not stand at its desire position after the resuming the game. That fault I have found in other game developed by other developer also. So please provide some guidance for it. I also tried with mScene.onUpdate(0) and mScene.onUpdate(1) but I does not able to found anything new from it.


I think it is caused by a spike in CPU usage when you resume the game. Box2D works on a best-effort basis so when the CPU is being overloaded momentarily, the Box2D execution drops to too small a number of steps per second. This causes problems.

There are two things you can do to improve the situation. a) Let the engine sleep for a while after the resume button is pressed. b) Implement MaxStepPhysicsWorld, you will find it on the AndEngine forums. It allows you to set a minimum steps the engine has to calculate each second and if it cannot keep up, the execution will slow down but it will not break down like this.

| improve this answer | |
  • \$\begingroup\$ It's a physics simulation problem, most physics engines use the last step to help with the next step. In this case the last step is a few million years ago in dog years, so it does the best it can. CPU spiking probably isn't at work here, read up on Verlet Integration which is a fairly common technique used in phsyics. \$\endgroup\$ – Patrick Hughes Jul 29 '12 at 16:10
  • \$\begingroup\$ What you said is compatible with what I said - the last step is indeed too long ago, but it is caused by the fact that when the CPU is under load, the engine cannot keep up and makes steps that are too large. \$\endgroup\$ – JohnEye Jul 30 '12 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.