Maison >base de données >tutoriel mysql >cocos2dx场景间切换效果

cocos2dx场景间切换效果

WBOY
WBOYoriginal
2016-06-07 15:43:37947parcourir

1.使用方法: 正常的无过渡场景的如果尚未建立场景(即游戏中的第一个场景),就是用pDirector-runWithScene(pScene);即可以使用相应场景。 如果是替换场景,则使用CCDirector::sharedDirector()-replaceScene(this);替换相应的场景即可。 而如果要使用场景

1.使用方法:

正常的无过渡场景的如果尚未建立场景(即游戏中的第一个场景),就是用pDirector->runWithScene(pScene);即可以使用相应场景。

如果是替换场景,则使用CCDirector::sharedDirector()->replaceScene(this);替换相应的场景即可。

而如果要使用场景间的切换效果来切换场景,则需要使用相应的切换方法即transitionWithDuration(当然不同效果的使用方法略有不同)生成相应场景,然后再通过CCDirector::sharedDirector()->replaceScene(this)来启动场景,也就是说这个给这个场景加了一个外包装,然后再启动,那么,这个场景就不是直接显示了,而是在场景的效果使用完了以后进入场景,起到过渡的效果。

一般此函数有两个参数,第一个是特效的切换时间,直接生成一个CCTime即可,例子中设定的时间是1.2s,对于很多场景的显示都很舒服,第二个是要进入的场景,有的会有第三个参数,会在下面介绍

2.test中的效果总结

CCTransitionJumpZoom::transitionWithDuration(t, s);//跳跃式,本场景先会缩小,然后跳跃进来

CCTransitionFade::transitionWithDuration(t, s);//淡出淡入,原场景淡出,新场景淡入

CCTransitionFade::transitionWithDuration(t, s, ccWHITE);//如果上一个的函数,带3个参数,则第三个参数就是淡出淡入的颜色

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);//场景从下移入推出原场景

以下三个需要检测opengl版本是否支持CCConfiguration::sharedConfiguration()->getGlesVersion()

CCTransitionCrossFade::transitionWithDuration(t,s);//淡出淡入交叉,同时进行

CCTransitionRadialCCW::transitionWithDuration(t,s);//时针切入

CCTransitionRadialCW::transitionWithDuration(t,s);//时针切入

以下两个需要先设置摄像机,使用CCDirector::sharedDirector()->setDepthTest(true);

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);//按列切

 

http://www.cnblogs.com/linux-ios/archive/2013/04/09/3010779.html

<span>//</span><span>  CCTransitionJumpZoom
</span><span>//</span><span>    作用: 创建一个跳动的过渡动画
</span><span>//</span><span>    参数1:过渡动作的时间
</span><span>//</span><span>    参数2:切换到目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionJumpZoom ::create(t , s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionProgressRadialCCW
    </span><span>//</span><span>    作用: 创建一个扇形条形式的过渡动画, 逆时针方向
    </span><span>//</span><span>    参数1:过渡动作的时间
    </span><span>//</span><span>    参数2:切换到目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionProgressRadialCCW::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionProgressRadialCW
    </span><span>//</span><span>    作用: 创建一个扇形条形式的过渡动画, 顺时针方向
    </span><span>//</span><span>    参数1:过渡动作的时间
    </span><span>//</span><span>    参数2:切换到目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionProgressRadialCW::create(t,s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
    </span><span>//</span><span>    CCTransitionProgressHorizontal
    </span><span>//</span><span>    作用: 创建一个水平条形式的过渡动画,  
    </span><span>//</span><span>    参数1:过渡动作的时间
    </span><span>//</span><span>    参数2:切换到目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionProgressHorizontal ::create(t,s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionProgressVertical
    </span><span>//</span><span>    作用: 创建一个垂直条形式的过渡动画,
    </span><span>//</span><span>    参数1:过渡动作的时间
    </span><span>//</span><span>    参数2:切换到目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionProgressVertical::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

    
</span><span>//</span><span>    CCTransitionProgressInOut
    </span><span>//</span><span>    作用: 创建一个由里向外扩展的过渡动画,
    </span><span>//</span><span>    参数1:过渡动作的时间
    </span><span>//</span><span>    参数2:切换到目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionProgressInOut::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

</span><span>//</span><span>    CCTransitionProgressOutIn
    </span><span>//</span><span>    作用: 创建一个由外向里扩展的过渡动画,
    </span><span>//</span><span>    参数1:过渡动作的时间
    </span><span>//</span><span>    参数2:切换到目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionProgressOutIn::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

</span><span>//</span><span>    CCTransitionCrossFade
</span><span>//</span><span>    作用:创建一个逐渐透明的过渡动画
    </span><span>//</span><span>    参数1:过渡动作的时间
    </span><span>//</span><span>    参数2:切换到目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionCrossFade::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionPageTurn
</span><span>//</span><span>    作用:创建一个翻页的过渡动画
</span><span>//</span><span>    参数1:过渡动作持续的时间
</span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    参数3:是否逆向翻页
</span><span>//</span><span>    reScene = CCTransitionPageTurn::create(t, s, false);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

</span><span>//</span><span>    CCTransitionFadeTR
</span><span>//</span><span>    作用:创建一个部落格过渡动画, 从左下到右上
    </span><span>//</span><span>    参数1:过渡动作持续的时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene =CCTransitionFadeTR::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionFadeBL
    </span><span>//</span><span>    作用:创建一个部落格过渡动画, 从右上到左下
    </span><span>//</span><span>    参数1:过渡动作持续的时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionFadeBL::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionFadeUp
    </span><span>//</span><span>    作用:创建一个从下到上,条形折叠的过渡动画
    </span><span>//</span><span>    参数1:过渡动作持续的时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene= CCTransitionFadeUp::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(s);

</span><span>//</span><span>    CCTransitionFadeDown
    </span><span>//</span><span>    作用:创建一个从上到下,条形折叠的过渡动画
    </span><span>//</span><span>    参数1:过渡动作持续的时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionFadeDown::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

</span><span>//</span><span>    CCTransitionTurnOffTiles
</span><span>//</span><span>    作用:创建一个随机方格消失的过渡动画
</span><span>//</span><span>    参数1:过渡动作的持续时间
</span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene= CCTransitionTurnOffTiles::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionSplitRows
</span><span>//</span><span>    作用:创建一个分行划分切换的过渡动画
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionSplitRows::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

</span><span>//</span><span>    CCTransitionSplitCols
    </span><span>//</span><span>    作用:创建一个分列划分切换的过渡动画
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionSplitCols::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionFade
</span><span>//</span><span>    作用:创建一个逐渐过渡到目标颜色的切换动画
</span><span>//</span><span>    参数1:过渡动作的持续时间
</span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    参数3:目标颜色
</span><span>//</span><span>    reScene= CCTransitionFade::create(t, s, ccc3(255, 0, 0));
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionFlipX
</span><span>//</span><span>    作用:创建一个x轴反转的切换动画
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
    </span><span>//</span><span>    参数3:反转类型的枚举变量   左右上下
</span><span>//</span><span>    kOrientationDownOver kOrientationLeftOver kOrientationRightOver  kOrientationUpOver
</span><span>//</span><span>    reScene  = CCTransitionFlipX::create(t, s, kOrientationRightOver);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

</span><span>//</span><span>    CCTransitionFlipY
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
    </span><span>//</span><span>    参数3:反转类型的枚举变量   左右上下
</span><span>//</span><span>    reScene = CCTransitionFlipY::create(t, s
</span><span>//</span><span>                                        , kOrientationDownOver);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

</span><span>//</span><span>    CCTransitionFlipAngular
</span><span>//</span><span>    作用:创建一个带有反转角切换动画
    </span><span>//</span>        <span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
    </span><span>//</span><span>    参数3:反转类型的枚举变量   左右上下
</span><span>//</span><span>    reScene = CCTransitionFlipAngular::create(t, s, kOrientationLeftOver);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionZoomFlipX
</span><span>//</span><span>     作用:创建一个带有缩放的x轴反转切换的动画
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
    </span><span>//</span><span>    参数3:反转类型的枚举变量   左右上下
</span><span>//</span><span>    reScene=CCTransitionZoomFlipX::create(t, s, kOrientationLeftOver);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionZoomFlipY
    </span><span>//</span><span>     作用:创建一个带有缩放的Y轴反转切换的动画
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
    </span><span>//</span><span>    参数3:反转类型的枚举变量   左右上下
</span><span>//</span><span>    reScene=CCTransitionZoomFlipY::create(t, s, kOrientationDownOver);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
   
    </span><span>//</span><span>    CCTransitionZoomFlipAngular
    </span><span>//</span><span>     作用:创建一个带有缩放 ,反转角切换的动画
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
    </span><span>//</span><span>    参数3:反转类型的枚举变量   左右上下
</span><span>//</span><span>    reScene=CCTransitionZoomFlipAngular::create(t, s, kOrientationRightOver);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionShrinkGrow
</span><span>//</span><span>    创建一个放缩交替的过渡动画
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionShrinkGrow::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionRotoZoom
   </span><span>//</span><span> 创建一个旋转放缩交替的过渡动画
   </span><span>//</span><span> 参数1:过渡动作的持续时间
   </span><span>//</span><span> 参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionRotoZoom::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionMoveInL
</span><span>//</span><span>    作用:创建一个从左边推入覆盖的过渡动画
    </span><span>//</span><span> 参数1:过渡动作的持续时间
    </span><span>//</span><span> 参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionMoveInL::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

</span><span>//</span><span>    CCTransitionMoveInR
    </span><span>//</span><span>    作用:创建一个从右边推入覆盖的过渡动画
    </span><span>//</span><span> 参数1:过渡动作的持续时间
    </span><span>//</span><span> 参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionMoveInR::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
</span><span>//</span><span>    CCTransitionMoveInB
    </span><span>//</span><span>    作用:创建一个从下边推入覆盖的过渡动画
    </span><span>//</span><span> 参数1:过渡动作的持续时间
    </span><span>//</span><span> 参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionMoveInB::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
    </span><span>//</span><span>    CCTransitionMoveInT
    </span><span>//</span><span>    作用:创建一个从上边推入覆盖的过渡动画
    </span><span>//</span><span> 参数1:过渡动作的持续时间
    </span><span>//</span><span> 参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene = CCTransitionMoveInT::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

</span><span>//</span><span>    CCTransitionSlideInL
</span><span>//</span><span>    作用:创建一个从左侧推入并顶出旧场景的过渡动画
</span><span>//</span><span>    参数1:过渡动作的持续时间
</span><span>//</span><span>    参数2:切换的目标场景的对象    
</span><span>//</span><span>    reScene  =CCTransitionSlideInL::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);

</span><span>//</span><span>    CCTransitionSlideInR
    </span><span>//</span><span>    作用:创建一个从右侧推入并顶出旧场景的过渡动画
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene  =CCTransitionSlideInR::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
    
    </span><span>//</span><span>    CCTransitionSlideInT
    </span><span>//</span><span>    作用:创建一个从顶部推入并顶出旧场景的过渡动画
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象
</span><span>//</span><span>    reScene  =CCTransitionSlideInT::create(t, s);
</span><span>//</span><span>    CCDirector::sharedDirector()->replaceScene(reScene);
    
    </span><span>//</span><span>    CCTransitionSlideInB
    </span><span>//</span><span>    作用:创建一个从下部推入并顶出旧场景的过渡动画
    </span><span>//</span><span>    参数1:过渡动作的持续时间
    </span><span>//</span><span>    参数2:切换的目标场景的对象</span>
    reScene  =<span>CCTransitionSlideInB::create(t, s);
    CCDirector::sharedDirector()</span>-><span>replaceScene(reScene);
    </span>


Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn