Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
    
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. –  Patrick Hughes Jul 29 '12 at 16:10
    
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. –  JohnEye Jul 30 '12 at 11:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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