1. Apparently I made mistake in my full game tutorial articles series. There were some issues, because there was unnecessary check inside onDestroy() method inside our activity code. This is proper form (previously there was check for is game loaded flag which caused issues!) Proper form:
@Override
protected void onDestroy()
{
super.onDestroy();
System.exit(0);
}
I have also updated AndroidManifest.xml file, adding configChange property fixing some issues while resuming our game, which is really important.
android:configChanges="keyboard|keyboardHidden|orientation
|screenLayout|uiMode|screenSize|smallestScreenSize|mcc|mnc"
Articles part
two and part
seven were updated with fixes mentioned above. I have also uploaded updated source file of the project in the last article, part
fifteen.
2. Performance advice of the day: recently I noticed that many people are making the same issue, mistake related to restarting of your game/level. Many people mistakenly register many update handlers to the ENGINE instead of to the SCENE. For example FPS logger, like:
engine.registerUpdateHandler(new FPSLogger());
And now lets say we perform game restart (disposing game scene, and initializing it again) Conclusion? Since update handler was registered to the engine, not to the scene, and it has not been unregistered manually, while initializing our scene after restart again, another instance of update handler is registered, over and over. So we have two choices:
- register update handlers to the scene, so you will not have to remember about un registering them while restarting your game scene.
- or remember to unregister update handler from engine before registering the same again
Preventing from duplicating update handlers is really important, since update handlers are executed on regular basis, it might be important performance tip.