例如从一个场景 进入另一个场景:
CCScene *s= MainGame::scene(); CCDirector::sharedDirector()->replaceScene(CCTransitionTurnOffTiles::transitionWithDuration(3, s)); //跳跃式,本场景先会缩小,新场景跳跃进来 //CCDirector::sharedDirector()->replaceScene(CCTransitionJumpZoom::transitionWithDuration(3,s)); //依次测试其它切换效果 //CCDirector::sharedDirector()->replaceScene(CCTransitionFade::transitionWithDuration(3, s)); //CCDirector::sharedDirector()->replaceScene(CCTransitionFlipY::transitionWithDuration(3, s,kOrientationRightOver)); //CCDirector::sharedDirector()->replaceScene(CCTransitionZoomFlipAngular::transitionWithDuration(3, s,kOrientationRightOver));
其它切换效果有:
CCTransitionJumpZoom::transitionWithDuration(t, s);//跳跃式,原场景先会缩小,新场景跳跃进来
CCTransitionFade::transitionWithDuration(t, s);//淡出淡入,原场景淡出,新场景淡入
CCTransitionFade::transitionWithDuration(t, s, ccRED);//第三个参数就是淡出淡入的颜色,默认是黑色
CCTransitionFlipX::transitionWithDuration(t, s, kOrientationLeftOver);//x轴左翻
CCTransitionFlipX::transitionWithDuration(t, s, kOrientationRightOver);//x轴右翻
CCTransitionFlipY::transitionWithDuration(t, s, kOrientationUpOver);//y轴上翻
CCTransitionFlipY::transitionWithDuration(t, s, kOrientationDownOver);//y轴下翻
CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver);//带角度转的左翻
CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationRightOver);//带角度转的右翻
CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationLeftOver);//带缩放效果x轴左翻
CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationRightOver);//带缩放效果x轴右翻
CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationUpOver);//带缩放效果y轴上翻
CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationDownOver);//带缩放效果y轴下翻
CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver);//带缩放效果/有角度转的左翻
CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationRightOver);//带缩放效果有角度转的右翻
CCTransitionShrinkGrow::transitionWithDuration(t, s);//交错换
CCTransitionRotoZoom::transitionWithDuration(t, s);//旋转效果
CCTransitionMoveInL::transitionWithDuration(t, s);//新场景从左移入覆盖
CCTransitionMoveInR::transitionWithDuration(t, s);//新场景从右移入覆盖
CCTransitionMoveInT::transitionWithDuration(t, s);//新场景从上移入覆盖
CCTransitionMoveInB::transitionWithDuration(t, s);//新场景从下移入覆盖
CCTransitionSlideInL::transitionWithDuration(t, s);//新场景从左移入推出原场景
CCTransitionSlideInR::transitionWithDuration(t, s);//新场景从右移入推出原场景
CCTransitionSlideInT::transitionWithDuration(t, s);//新场景从上移入推出原场景
CCTransitionSlideInB::transitionWithDuration(t, s);//新场景从下移入推出原场景
CCTransitionCrossFade::transitionWithDuration(t,s);//淡出淡入交叉,同时进行
CCTransitionPageTurn::transitionWithDuration(t, s, false);//翻页,前翻
CCTransitionPageTurn::transitionWithDuration(t, s, true);//翻页,后翻
CCTransitionFadeTR::transitionWithDuration(t, s);//向右上波浪
CCTransitionFadeBL::transitionWithDuration(t, s);//向左下波浪
CCTransitionFadeUp::transitionWithDuration(t, s);//向上百叶窗
CCTransitionFadeDown::transitionWithDuration(t, s);//向下百叶窗
CCTransitionTurnOffTiles::transitionWithDuration(t, s);//随机小方块
CCTransitionSplitRows::transitionWithDuration(t, s);//按行切
CCTransitionSplitCols::transitionWithDuration(t, s);//按列切
【注】
cocos2d-x 从2.x之后好api也随之改变,如果你的code出现 没有成员transitionWithDuration之类将其方法替换为create即可参数不变。
http://blog.csdn.net/m_changgong/article/details/8743965