Reset/reboot/restart the cocos2d application

Reset/reboot/restart the cocos2d application
0.0 0


Hi, I’m developing a game with cocos2d-x jsb.
I have built a hot update system for the game. But every time when the game complete the update, I want the game restart automatically.
So the engine could have a chance to purge all cached data and start over again for some of the resources may have changed since the update.

I am thinking a way to restart CCDirector gracefully( means with cross platform support ).
CCDirector can be shutdown by pop all scenes out of stack. Then CCDirector will die after a frame.
Then I want to find a proper point to call CCApplication::run to restart all the things. But I failed to found one.

Any someone familiar with cocos2d-x low level components life cycle, can you give me some hints to do this?


try this:

ScriptingCore* sc = ScriptingCore::getInstance();



Put your restarting coding in the native wrapper, the activity or view controller, depending on the OS you’re supporting. Restarting the application in main.cpp for Win32 is easy, just re-up all the contexts after clearing the old ones. Slightly more complex in Android, but if you’re feeling lazy just abort the activity and re-launch it. Slower than re-building the CC2d-x context in activity, but easier to code :wink:


Must have been code for C++ i guess?