cocos2d-x场景切换与过渡效果

场景切换

 

void MyScene::daySceneCallback(CCObject *pSender)
{
    CCScene *scene = 
new MyScene();
    CCLayer *pLayer = 
new LayerDay();
    scene->addChild(pLayer, 
0);
    CCDirector::sharedDirector()->pushScene(scene);
    scene->release();
    pLayer->release();
}

 

带过渡效果

void MyScene::daySceneCallback(CCObject *pSender)
{
    CCScene *scene = 
new MyScene();
    CCLayer *pLayer = 
new LayerDay();
    scene->addChild(pLayer, 
0);
    CCTransitionJumpZoom *pScene = CCTransitionJumpZoom::create(
1.2f, scene); //note
    //CCDirector::sharedDirector()->pushScene(pScene);
    //CCDirector::sharedDirector()->pushScene(scene);
    CCDirector::sharedDirector()->replaceScene(pScene);
    scene->release();
    
//pScene->release();//note
    pLayer->release();
}

注意切换场景带过渡效果时使用replaceScene函数

posted @ 2013-07-17 09:55  java程序员-c  阅读(222)  评论(0编辑  收藏  举报