日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

cocos2dx基础篇(26)——场景切换CCTransitionScene

發(fā)布時(shí)間:2025/3/15 编程问答 11 豆豆
生活随笔 收集整理的這篇文章主要介紹了 cocos2dx基础篇(26)——场景切换CCTransitionScene 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

【嘮叨】

????游戲中兩個(gè)場(chǎng)景的切換時(shí)經(jīng)常要被用到的,cocos2dx引擎為我們提供了許多場(chǎng)景切換的動(dòng)畫,我感覺有些和PPT的切換很類似,所以感覺很熟悉。如:淡入淡出、翻頁(yè)、跳入跳出等等。

????本節(jié)要講的場(chǎng)景切換CCTransitionScene方式十分豐富,不過內(nèi)容比較簡(jiǎn)單,很容易掌握。


【致謝】

????http://gl.paea.cn/contents/d4d676f371519df4.html


【3.x】

? ? (1)去掉?“CC”

????(2)卡牌翻轉(zhuǎn) TransitionFlip 中的樣式?tOrientation

////1:?kCCTransitionOrientationLeftOver??(左向右翻轉(zhuǎn))//2:?kCCTransitionOrientationRightOver?(右向左翻轉(zhuǎn))//3:?kCCTransitionOrientationUpOver????(下向上翻轉(zhuǎn))//4:?kCCTransitionOrientationDownOver??(上向下翻轉(zhuǎn)) //

????????改為強(qiáng)枚舉?TransitionScene::Orientation::

//LEFT_OVER???????????????//左向右翻轉(zhuǎn)RIGHT_OVER??????????????//右向左翻轉(zhuǎn)UP_OVER?????????????????//下向上翻轉(zhuǎn)DOWN_OVER???????????????//上向下翻轉(zhuǎn) //

????(3)其他變化不大。




【場(chǎng)景管理】

????在講場(chǎng)景切換CCTransitionScene之前,先來復(fù)習(xí)一下場(chǎng)景CCScene的管理。

????游戲運(yùn)行的過程中,每次只能運(yùn)行一個(gè)場(chǎng)景,所以要切換到其他場(chǎng)景的話,需要對(duì)場(chǎng)景進(jìn)行相應(yīng)的管理。而對(duì)場(chǎng)景的管理則是由導(dǎo)演類CCDirector來進(jìn)行操作的。

????

1、使用方法

////獲取一個(gè)單例對(duì)象CCDirector::sharedDirector()->replaceScene(newScene); //


2、場(chǎng)景管理操作

//void?runWithScene(CCScene?*pScene);??//進(jìn)入AppDelegate主循環(huán)運(yùn)行的場(chǎng)景,僅在運(yùn)行第一個(gè)場(chǎng)景時(shí)調(diào)用void?pushScene(CCScene?*pScene);?????//暫停當(dāng)前場(chǎng)景,push到場(chǎng)景堆棧,運(yùn)行新場(chǎng)景void?popScene();?????????????????????//從場(chǎng)景堆棧中pop場(chǎng)景,刪除當(dāng)前場(chǎng)景(不入棧)void?popToRootScene();???????????????//從場(chǎng)景堆棧中pop出所有場(chǎng)景,棧底場(chǎng)景替換當(dāng)前場(chǎng)景,刪除當(dāng)前場(chǎng)景(不入棧)void?replaceScene(CCScene?*pScene);??//場(chǎng)景替換,刪除當(dāng)前場(chǎng)景(不入棧)void?pause();????????????????????????//暫停當(dāng)前場(chǎng)景void?resume();???????????????????????//恢復(fù)被暫停的當(dāng)前場(chǎng)景void?end();??????????????????????????//終止執(zhí)行,釋放運(yùn)行中的場(chǎng)景 //




【CCTransitionScene】

????CCTransitionScene繼承于CCScene,主要用于處理場(chǎng)景之間切換動(dòng)畫的管理。而我們主要關(guān)注的是它派生出來個(gè)各類場(chǎng)景切換動(dòng)畫效果的子類,及這些子類的使用方法。

????由場(chǎng)景管理可知,場(chǎng)景切換有關(guān)的函數(shù)操作有兩個(gè):pushScenereplaceScene

????故可以在使用這兩個(gè)函數(shù)進(jìn)行場(chǎng)景切換時(shí),加入場(chǎng)景切換動(dòng)畫效果,增加游戲的美感。


1、常用的場(chǎng)景切換類

////慢慢淡化到另一場(chǎng)景CCTransitionCrossFade::create(時(shí)間,目標(biāo)場(chǎng)景);//變暗消失后,另一場(chǎng)景慢慢出現(xiàn)CCTransitionFade::create(時(shí)間,目標(biāo)場(chǎng)景);//翻頁(yè),true為向前翻頁(yè)CCTransitionPageTurn::create(時(shí)間,目標(biāo)場(chǎng)景,bool);?//變小跳動(dòng)消失后,另一場(chǎng)景跳動(dòng)變大出現(xiàn)CCTransitionJumpZoom::create(時(shí)間,目標(biāo)場(chǎng)景);//旋轉(zhuǎn)變小消失后,另一場(chǎng)景旋轉(zhuǎn)變大出現(xiàn)CCTransitionRotoZoom::create(時(shí)間,目標(biāo)場(chǎng)景);//變小消失,同時(shí)另一場(chǎng)景變大出現(xiàn)CCTransitionShrinkGrow::create(時(shí)間,目標(biāo)場(chǎng)景);//剝落場(chǎng)景,呈現(xiàn)出另一個(gè)場(chǎng)景CCTransitionFadeBL::create(時(shí)間,目標(biāo)場(chǎng)景);???//右上到左下方塊消失CCTransitionFadeDown::create(時(shí)間,目標(biāo)場(chǎng)景);?//上到下橫條消失CCTransitionFadeTR::create(時(shí)間,目標(biāo)場(chǎng)景);???//左下到右上方塊消失CCTransitionFadeUp::create(時(shí)間,目標(biāo)場(chǎng)景);???//從下到上橫條消失//卡牌翻轉(zhuǎn)//樣式(可以不寫)://1:?kCCTransitionOrientationLeftOver??(左向右翻轉(zhuǎn))//2:?kCCTransitionOrientationRightOver?(右向左翻轉(zhuǎn))//3:?kCCTransitionOrientationUpOver????(下向上翻轉(zhuǎn))//4:?kCCTransitionOrientationDownOver??(上向下翻轉(zhuǎn))CCTransitionFlipAngular::create(時(shí)間,目標(biāo)場(chǎng)景,樣式12);?????//翻轉(zhuǎn)CCTransitionFlipX::create(時(shí)間,目標(biāo)場(chǎng)景,樣式12);???????????//X軸翻轉(zhuǎn)CCTransitionFlipY::create(時(shí)間,目標(biāo)場(chǎng)景,樣式34);???????????//Y軸翻轉(zhuǎn)CCTransitionZoomFlipAngular::create(時(shí)間,目標(biāo)場(chǎng)景,樣式12);?//翻轉(zhuǎn)???,區(qū)別是附帶回拉效果CCTransitionZoomFlipX::create(時(shí)間,目標(biāo)場(chǎng)景,樣式12);???????//X軸翻轉(zhuǎn),區(qū)別是附帶回拉效果CCTransitionZoomFlipY::create(時(shí)間,目標(biāo)場(chǎng)景,樣式34);???????//Y軸翻轉(zhuǎn),區(qū)別是附帶回拉效果//卡牌(另一場(chǎng)景)疊放,插放在場(chǎng)景上面CCTransitionMoveInB::create(時(shí)間,目標(biāo)場(chǎng)景);?//整體從下面插入CCTransitionMoveInL::create(時(shí)間,目標(biāo)場(chǎng)景);?//整體從左面插入CCTransitionMoveInT::create(時(shí)間,目標(biāo)場(chǎng)景);?//整體從上面插入CCTransitionMoveInR::create(時(shí)間,目標(biāo)場(chǎng)景);?//整體從右面插入//刷墻,矩形。(另一個(gè)場(chǎng)景像刷墻一樣刷出來)CCTransitionProgressHorizontal::create(時(shí)間,目標(biāo)場(chǎng)景);?//從左到右CCTransitionProgressVertical::create(時(shí)間,目標(biāo)場(chǎng)景);???//從上到下CCTransitionProgressInOut::create(時(shí)間,目標(biāo)場(chǎng)景);??????//從中間到四周CCTransitionProgressOutIn::create(時(shí)間,目標(biāo)場(chǎng)景);??????//從四周到中間//刷墻,扇形。(另一個(gè)場(chǎng)景像刷墻一樣刷出來)CCTransitionProgre***adialCCW::create(時(shí)間,目標(biāo)場(chǎng)景);??//逆時(shí)針CCTransitionProgre***adialCW::create(時(shí)間,目標(biāo)場(chǎng)景);???//順時(shí)針//刷墻,分成很多小塊。(一小塊一小塊的隨機(jī)刷上去)CCTransitionTurnOffTiles::create(時(shí)間,目標(biāo)場(chǎng)景);//滑動(dòng),滑出窗口。另一場(chǎng)景滑入窗口CCTransitionSlideInB::create(時(shí)間,目標(biāo)場(chǎng)景);??//向上滑動(dòng)CCTransitionSlideInL::create(時(shí)間,目標(biāo)場(chǎng)景);??//向右滑動(dòng)CCTransitionSlideInR::create(時(shí)間,目標(biāo)場(chǎng)景);??//向左滑動(dòng)CCTransitionSlideInT::create(時(shí)間,目標(biāo)場(chǎng)景);??//向下滑動(dòng)//場(chǎng)景分裂成三塊矩形,抽走消失。另一場(chǎng)景也成三塊插入出現(xiàn)CCTransitionSplitCols::create(時(shí)間,目標(biāo)場(chǎng)景);?//中間塊向上,左右塊向下抽出CCTransitionSplitRows::create(時(shí)間,目標(biāo)場(chǎng)景);?//中間塊向右,上下塊向左抽出 //


2、使用方法

////創(chuàng)建場(chǎng)景HelloWorld場(chǎng)景CCScene*?scene?=?HelloWorld::scene();//創(chuàng)建場(chǎng)景切換方式CCTransitionScene*?ts?=?CCTransitionJumpZoom::create(2,?scene);//切換場(chǎng)景CCDirector::sharedDirector()->replaceScene(ts); //




【代碼實(shí)戰(zhàn)】

????請(qǐng)參考官方給出的TestCpp項(xiàng)目中相關(guān)知識(shí)來學(xué)習(xí),里面講的很詳細(xì)。



轉(zhuǎn)載于:https://blog.51cto.com/shahdza/1547977

總結(jié)

以上是生活随笔為你收集整理的cocos2dx基础篇(26)——场景切换CCTransitionScene的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。