Tag Archives: cocos2d-x

Quitting your game without killing the Android process

I’m back with a small article on how to improve Android Cocos2D-X based games. To quit an Android game when pressing Back, the engine sample tells you to call

  Director::getInstance()->end();

Now this the job in most cases, but has one major drawback: it doesn’t follow Android guidelines for finishing an Activity. Instead, it kills the whole Linux process hosting the Android game. This has implications if your game includes Android services (eg. for push notifications), because it kills the service as well. Therefore, your push notifications will not work properly.

So I had to come up with a fix. I implemented this C++ function which calls a native Java method:
Continue reading Quitting your game without killing the Android process