cocosd怎么在一定时间后场景切换
展开全部
仿造HelloWorldScene 写就好啦
COCOS2DX 是场景的切换,比如 菜单 场景 ,游戏 场景, 当你进入游戏 场景 ,菜单 场景就
会删掉,减少内存空间
所用你要切换场景的类都能仿造这个写
CCScene* HelloWorld::scene(){ CCScene * scene = NULL; do { // ;scene; is an autorelease object scene = CCScene::create(); CC_BREAK_IF(! scene);
// ;layer; is an autorelease object HelloWorld *layer = HelloWorld::create(); CC_BREAK_IF(! layer);
// add layer as a child to scene scene-;addChild(layer); } while (0);
// return the scene return scene;}
//切换场景过程
CCScene *pScene; g_iGameState = iType; if(iType == GAME_MENU) { pScene = CCTransitionFade::transitionWithDuration(1.0f, CGameMenu::scene()); } else if(iType == GAME_RUN) { pScene = CCTransitionFade::transitionWithDuration(1.0f, CGameSelectCus::scene()); } else if (iType == GAME_OVER) { pScene = CCTransitionFlipX::transitionWithDuration(2.0f, CGameOver::scene()); }
CCDirector::sharedDirector()-;replaceScene(pScene);
一个是创建 场景 ,一个是切换 ,CCTransitionFade::transitionWithDuration()这个是切换场景时候的动画效果
COCOS2DX 是场景的切换,比如 菜单 场景 ,游戏 场景, 当你进入游戏 场景 ,菜单 场景就
会删掉,减少内存空间
所用你要切换场景的类都能仿造这个写
CCScene* HelloWorld::scene(){ CCScene * scene = NULL; do { // ;scene; is an autorelease object scene = CCScene::create(); CC_BREAK_IF(! scene);
// ;layer; is an autorelease object HelloWorld *layer = HelloWorld::create(); CC_BREAK_IF(! layer);
// add layer as a child to scene scene-;addChild(layer); } while (0);
// return the scene return scene;}
//切换场景过程
CCScene *pScene; g_iGameState = iType; if(iType == GAME_MENU) { pScene = CCTransitionFade::transitionWithDuration(1.0f, CGameMenu::scene()); } else if(iType == GAME_RUN) { pScene = CCTransitionFade::transitionWithDuration(1.0f, CGameSelectCus::scene()); } else if (iType == GAME_OVER) { pScene = CCTransitionFlipX::transitionWithDuration(2.0f, CGameOver::scene()); }
CCDirector::sharedDirector()-;replaceScene(pScene);
一个是创建 场景 ,一个是切换 ,CCTransitionFade::transitionWithDuration()这个是切换场景时候的动画效果
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询