Skip to content Skip to sidebar Skip to footer

How To Kill Cocos2d-x Test App

We are creating an SDK that is used in Cocos2d-x games (on Android/iOS). As part of development, we have setup a test framework for running various tests on a real device (Android

Solution 1:

The sample project HelloCpp has an exit button in its example. Look at HelloWorldScene.cpp and at the function call back menuCloseCallback (function might vary a bit based on version of cocos2dx you are on)

voidHelloWorld::menuCloseCallback(CCObject* pSender){
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
    CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)exit(0);
#endif#endif
}

For android the answer would be CCDirector::sharedDirector()->end();

Note that I don't think Apple will approve you if your app calls exit(0).

Post a Comment for "How To Kill Cocos2d-x Test App"