nicolasgramlich / AndEngine

Free Android 2D OpenGL Game Engine
http://www.andengine.org
Apache License 2.0
3.18k stars 1.35k forks source link

All engine is reinitialized after unlock the device #26

Open dryaz opened 12 years ago

dryaz commented 12 years ago

When you press power button in game the device locks and after unlock it with power button AndEngine reinitialize the whole game and resources and all the level progress is lost. (When you use "home button" and return to the game all the game is on the last state and progress is saved). Is it possible to prevent reinitializing of resources (if android doesn't kill the activity)? (there is a way to save the state with xml\json etc but i think it is not the best solution).

nicolasgramlich commented 12 years ago

What branch/revision and android version are you on?

EGL Context Lost

There are situations where the EGL rendering context will be lost. 
This typically happens when device wakes up after going to sleep. 
When the EGL context is lost, all OpenGL resources (such as textures)
that are associated with that context will be automatically deleted. 
In order to keep rendering correctly, a renderer must recreate any 
lost resources that it still needs. The onSurfaceCreated(GL10, EGLConfig) 
method is a convenient place to do this.
dryaz commented 12 years ago

The current built branch is: 1037:42ca5fbb1d68@default (have taken from andegine wiki) android version 2.3.3

I've thought about loosing the context. I've tried to save only the scene and then onResume load it, everything is fine but there are no resources (engine lost them after recreate).

I only looking for the best way to save game progress in game.