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

时间:2021-04-30 19:37:12

场景切换

void  MyScene::daySceneCallback(CCObject *pSender)
{
    CCScene *scene = 
new
 MyScene();
    CCLayer *pLayer = 
new
 LayerDay();
    scene->addChild(pLayer,

);
    CCDirector::sharedDirector()->pushScene(scene);
    scene->release();
    pLayer->release();
}

带过渡效果

.2f, scene); //note
    //CCDirector::sharedDirector()->pushScene(pScene);
    //CCDirector::sharedDirector()->pushScene(scene);
    CCDirector::sharedDirector()->replaceScene(pScene);
    scene->release();
    //pScene->release();//note
    pLayer->release();
}

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