cocos2dx 在多场景切换中,生命周期打印的效果如下:
从 MyScene 场景进入,切换到 HelloWorld 场景,再推出 HelloWorld 场景,流程图(见附件,,,,不知道怎么上传图片,不能粘贴图,郁闷。。。)
打印 log 如下,
MyScene代码:MyScene::MyScene(){ cclog("wangss------------->MyScene");}MyScene::~MyScene(){ cclog("wangss------------->~~MyScene");}voIDMyScene::onEnter(){ cclog("wangss------------->onEnter"); Layer::onEnter();}voIDMyScene::onEnterTransitionDIDFinish(){ cclog("wangss------------->onEnterTransitionDIDFinish");}voIDMyScene::onExit(){ cclog("wangss------------->onExit"); Layer::onExit();}voIDMyScene::onExitTransitionDIDStart(){ cclog("wangss------------->onExitTransitionDIDStart");}voIDMyScene::cleanup(){ cclog("wangss------------->cleanup");}Scene*MyScene::createScene(){ cclog("wangss------------->createScene"); autoscene=Scene::create(); autolayer=MyScene::create(); scene->addChild(layer); returnscene;}boolMyScene::init(){ cclog("wangss------------->init"); if(!Layer::init()){ returnfalse; } SizevisibleSize=Director::getInstance()->getVisibleSize(); Vec2origin=Director::getInstance()->getVisibleOrigin(); //spriteTest(visibleSize); //labelTest(visibleSize); //menuTest(visibleSize); //languageTest(visibleSize); //scheduleTest(visibleSize); //scaleNinespriteTest(visibleSize); //shujujIEgouTest(visibleSize); //actionTest(visibleSize); //actionCallBackTest(visibleSize); //frameAnimationTest(visibleSize); //actionEaseTest(visibleSize); //progressActionTest(visibleSize); lifeCycleTest(visibleSize); returntrue;}HelloWorld代码:HelloWorld::HelloWorld(){ cclog("wangss------HelloWorld------->HelloWorld");}HelloWorld::~HelloWorld(){ cclog("wangss------HelloWorld------->~~HelloWorld");}voIDHelloWorld::onEnter(){ cclog("wangss------HelloWorld------->onEnter"); Layer::onEnter();}voIDHelloWorld::onEnterTransitionDIDFinish(){ cclog("wangss------HelloWorld------->onEnterTransitionDIDFinish");}voIDHelloWorld::onExit(){ cclog("wangss------HelloWorld------->onExit"); Layer::onExit();}voIDHelloWorld::onExitTransitionDIDStart(){ cclog("wangss------HelloWorld------->onExitTransitionDIDStart");}voIDHelloWorld::cleanup(){ cclog("wangss------HelloWorld------->cleanup");}Scene*HelloWorld::createScene(){ cclog("wangss------HelloWorld------->createScene");//'scene'isanautoreleaSEObjectautoscene=Scene::create();//'layer'isanautoreleaSEObjectautolayer=HelloWorld::create();//addlayerasachildtoscenescene->addChild(layer);//returnthescenereturnscene;}
11-02 15:09:40.290: D/cocos2d-x deBUG info(23066): wangss------------->createScene
11-02 15:09:40.300: D/cocos2d-x deBUG info(23066): wangss------------->MyScene
11-02 15:09:40.300: D/cocos2d-x deBUG info(23066): wangss------------->init
11-02 15:09:40.320: D/cocos2d-x deBUG info(23066): wangss------------->onEnter
11-02 15:09:40.320: D/cocos2d-x deBUG info(23066): wangss------------->onEnterTransitionDIDFinish
11-02 15:09:43.640: D/cocos2d-x deBUG info(23066): wangss------HelloWorld------->createScene
11-02 15:09:43.640: D/cocos2d-x deBUG info(23066): wangss------HelloWorld------->HelloWorld
11-02 15:09:43.640: D/cocos2d-x deBUG info(23066): wangss------HelloWorld------->init
11-02 15:09:43.760: D/cocos2d-x deBUG info(23066): wangss------------->onExitTransitionDIDStart
11-02 15:09:43.760: D/cocos2d-x deBUG info(23066): wangss------HelloWorld------->onEnter
11-02 15:09:44.940: D/cocos2d-x deBUG info(23066): wangss------------->onExit
11-02 15:09:44.940: D/cocos2d-x deBUG info(23066): wangss------HelloWorld------->onEnterTransitionDIDFinish
11-02 15:09:44.940: D/cocos2d-x deBUG info(23066): wangss------------->cleanup
11-02 15:09:44.940: D/cocos2d-x deBUG info(23066): wangss------------->~~MyScene
11-02 15:09:46.220: D/cocos2d-x deBUG info(23066): wangss------HelloWorld------->onExit
11-02 15:09:46.220: D/cocos2d-x deBUG info(23066): wangss------HelloWorld------->cleanup
11-02 15:09:46.220: D/cocos2d-x deBUG info(23066): wangss------HelloWorld------->~~HelloWorld
总结以上是内存溢出为你收集整理的cocos2dx Scene 生命周期(replaceScene,popScene后续补充)全部内容,希望文章能够帮你解决cocos2dx Scene 生命周期(replaceScene,popScene后续补充)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)