You could try to use the build-in android function:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
While having this in your Manifest.xml:
<activity android:name=".Activity_name"
android:configChanges="orientation">
To prevent your Game from getting restarted. You can catch those config changes with:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
//do something
}
else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
//do something
}
}
As described here: http://developer.android.com/guide/topics/resources/runtime-changes.html
I don't know if AndEngine will react kindly to this kind of change. The only other option in my mind would be to alter the EngineOptions
which, to my knowledge, is not possible outside the onLoadEngine
function.
The other obvious idea would be to just start a new Activity
with a new Engine
for the game itself.