Search code examples
androidcocos2d-x

multiple Cocos2dxActivity based activities eventually crash


I have an Android app with 5 Activities in it that are derived from Cocos2dxActivity.

Each activity is a short game/puzzle that the user plays in a random sequence. This works for around 10 starts, but eventually the Activity will crash, and the app will show the last activity from the back stack.

The log just contains a message like this:

I/Process﹕ Sending signal. PID: 15163 SIG: 9

I initially thought I must have a memory leak, but I've been through my code and I'm sure I free any memory I allocate. I do load textures using Cocos, but they should auto release.

When I want to leave the cocos activity I make a JNI Call to the Java activity from the C++ code, and call

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

Is there anything else I'm supposed to do when closing the Activity? Would upgrading from Cocos2d-x 3.0 help? I haven't seen anything that implies it would.


Solution

  • This is very vauge question, and without having access to your code, it is too hard to guess the reason. But I can definitely say that your method of combining 5 activities for 5 games is definitely not a proper way to do so.

    With cocos2dx you are supposed to hold on to your single activity and then make changes in your C++ code through adding different SCENES and switching between them rather than having different activities.