Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've found that after resuming my game the whole engine is reloaded and application is reinitialized. I want to save engine state and in "onResume," resume the game process from where it left off.

I've tried to save the engine (mEngine) and then after resume the game in "onLoadEngine" return saved engine. I think it is a bad solution and it doesn't work anyway.

What is the best solution for resuming my game (after the power key was pressed, for example) in AndEngine ?

share|improve this question
You may want to ask on their forums as well: – Byte56 Jan 26 '12 at 17:37
I've already asked there – dilix Jan 26 '12 at 18:02
up vote 4 down vote accepted

Since the game state is going to be specific to your game, there isn't built in functionality for this in the engine. One solution would be to write the state information you want to keep to an XML file. Likely you'd want to load this saved state in your onStart() function. But really that's up to you and how you want your game to behave.

There's a blog post about the flow between states, and when to save and load states:

And information on how to read/write a file:

share|improve this answer
Ok, thx, i know about this solution, but for my game it's rather difficult now (the game is already released without this functionality ("Draw and ride")). I've tried to save the Scene in local var tempScene, everything is ok and scene is loaded... but there is no handlers, modifiers etc =) – dilix Jan 26 '12 at 18:16
What difference between pause on "Home button" and pause on "power button" with turning off the screen ? "Home button" pause is implemented in sample provided by amb – dilix Jan 26 '12 at 18:18
I'm not sure what the difference is between home and power pauses, sorry. From my understanding, there are differences between pausing and locking. Likely the device is getting locked when the power button is pressed. As far as changes after the game has been released, you'll have to update either way, so I guess you need to decide if the difficulty of adding this is worth it to you and the hassle of updating for your customers. – Byte56 Jan 26 '12 at 18:36
"differences between pausing and locking" - i think it is the right way - and maybe OS can kill the procces after go to sleep and AndEngine decide that simpliest way to avoid it is to rebuild the whole app, thank you, i will think about it – dilix Jan 26 '12 at 18:55

This tutorial will help:

share|improve this answer
It is not really what i want - i've downloaded this sample and if i press power button the whole scene is rebuilt. When you press home button and then return to the game everything is ok, but after power button game is reset. – dilix Jan 26 '12 at 18:03

Your Answer


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.