Cocos2d 场景切换特效

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhenyu5211314/article/details/39617183

添加一个场景WelcomeScene

  1. #include "WelcomeScene.h"  
  2. #include "GameScene.h"  
  3.   
  4. using namespace cocos2d;  
  5.   
  6. CCScene* WelcomeScene::scene()  
  7. {  
  8.     CCScene * scene = NULL;  
  9.     do  
  10.     {  
  11.         scene=CCScene::create();  
  12.   
  13.         WelcomeScene* gameScene=WelcomeScene::create();  
  14.         scene->addChild(gameScene);  
  15.   
  16.   
  17.     }while(0);  
  18.   
  19.     return scene;  
  20. }  
  21.   
  22. bool WelcomeScene::init()  
  23. {  
  24.     this->setTouchEnabled(true);  
  25.     bool bRet = false;  
  26.     do  
  27.     {  
  28.         CCSprite* pMap = CCSprite::create("welcome_bg.png");  
  29.         CCSize size = CCDirector::sharedDirector()->getWinSize();  
  30.         pMap->setPosition(ccp(size.width/2, size.height/2));  
  31.         this->addChild(pMap, 0);  
  32.   
  33.         CCMenuItemImage *pCloseItem = CCMenuItemImage::create(  
  34.             "StartGameNormal.png",  
  35.             "StartGamePressed.png",  
  36.             this,  
  37.             menu_selector(WelcomeScene::menuStartCallback));  
  38.         CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);  
  39.         pMenu->setPosition(size.width/2,size.height/2);  
  40.         this->addChild(pMenu, 1);  
  41.               
  42.     }while(0);  
  43.   
  44.     bRet=true;  
  45.   
  46.     return bRet;  
  47. }  
  48.   
  49.   
  50. void WelcomeScene::menuStartCallback(CCObject* pSender)  
  51. {  
  52.     CCScene * scene=GameScene::scene();  
  53.     CCDirector::sharedDirector()->replaceScene(scene);  
  54. }  
在menuStartCallback()中通过导演来切换场景。


使用特效:

  1. CCDirector::sharedDirector()->replaceScene((CCTransitionSlideInR::create(1, scene)));  


网上找的特效:

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() <= GLES_VER_1_0如果为真则为不支持

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

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页