">

- bool Setting::init()
- {
- if( !Layer::init() )
- {
- returnfalse;
- }
-
- log("Settinginit");
- ......
- returntrue;
- }
-
- void Setting::onEnter()
- {
- Layer::onEnter();
- log("SettingonEnter");
- }
-
- void Setting::onEnterTransitionDidFinish()
- {
- Layer::onEnterTransitionDidFinish();
- log("SettingonEnterTransitionDidFinish");
- }
-
- void Setting::onExit()
- {
- Layer::onExit();
- log("SettingonExit");
- }
-
- void Setting::onExitTransitionDidStart()
- {
- Layer::onExitTransitionDidStart();
- log("SettingonExitTransitionDidStart");
- }
-
- void Setting::cleanup()
- {
- Layer::cleanup();
- log("Settingcleanup");
- }
情况1时候,它的调用顺序如下图所示。

情况2时候,它的调用顺序如下图所示,从图中可见与上面不同是多出HelloWorld中cleanup函数,这也说明replaceScene函数会释放场景对象。

情况3时候,它的调用顺序如下图所示,从图中可见popScene函数时候调用Setting中cleanup函数,这说明popScene函数会释放Setting场景对象,当回到HelloWorld场景时候并不会调用init()函数,而是调用onEnter函数。

欢迎加入cocos2d-x技术讨论群:257760386、327403678