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.

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: andengine.org/forums –  Byte56 Jan 26 '12 at 17:37
    
I've already asked there –  dilix Jan 26 '12 at 18:02
add comment

2 Answers 2

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: http://www.andengine.org/forums/post25660.html#p25660

And information on how to read/write a file: http://www.anddev.org/write_to_and_read_from_a_file-t3173.html

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
add comment

This tutorial will help:
https://jimmaru.wordpress.com/2011/09/28/andengine-simple-android-game-tutorial/

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
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.