• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            專(zhuān)職C++

            不能停止的腳步

              C++博客 :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
              163 Posts :: 7 Stories :: 135 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(28)

            我參與的團(tuán)隊(duì)

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            cocos2dx框架已經(jīng)提供了很多場(chǎng)景切換的類(lèi),但是一些自定義的場(chǎng)景切換,只有自己實(shí)現(xiàn)了。下面是實(shí)現(xiàn)的類(lèi)。這里設(shè)計(jì)的分辨率是750*500.請(qǐng)根據(jù)實(shí)際的要求調(diào)整。
            頭文件
            #ifndef _TRANSITION_GAME_H_
            #define _TRANSITION_GAME_H_
            #include <cocos2d.h>
            namespace cocos2d 
            {
                class CCTransitionGame : public CCTransitionScene
                {
                public:
                    CCTransitionGame();
                    virtual ~CCTransitionGame();
                    void onEnter();
                    static CCTransitionGame * create(float t, CCScene *scene);
                private:
                    void LRFinish(void);
                    void OnFirstActionFinish(void);
                private:
                    int m_FinishCnt;
                };
            }
            #endif
            源文件
            #include "TransitionGame.h"
            #include "xlog.h"
            #include <xstring.h>
            namespace cocos2d
            {
                using namespace zdh;
                CCTransitionGame * CCTransitionGame::create(float t, CCScene *scene)
                {
                    CCTransitionGame * pScene = new CCTransitionGame();
                    if (pScene && pScene->initWithDuration(t, scene))
                    {
                        pScene->autorelease();
                        return pScene;
                    }
                    CC_SAFE_DELETE(pScene);
                    return NULL;
                }

                CCTransitionGame::CCTransitionGame()
                {
                    m_FinishCnt = 0;
                }

                CCTransitionGame::~CCTransitionGame()
                {
                }

                void CCTransitionGame::onEnter()
                {
                    CCTransitionScene::onEnter();
                    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();


                    CCPoint stLeftBegin, stLeftEnd, stRightBegin, stRightEnd;
                    //設(shè)置左邊的起點(diǎn)和終點(diǎn)
                    stLeftBegin.setPoint(-436.0f, -60);
                    stLeftEnd.setPoint(visibleSize.width / 2.0f + stLeftBegin.x, -60.0f);
                    //設(shè)置右邊的起點(diǎn)和終點(diǎn)
                    stRightBegin.setPoint(visibleSize.width, -60.0f);
                    stRightEnd.setPoint(visibleSize.width / 2.0f, -60.0f);
                    //加載動(dòng)畫(huà)序列
                    CCSpriteFrameCache* pCache = CCSpriteFrameCache::sharedSpriteFrameCache();
                    pCache->addSpriteFramesWithFile("middle_ani_1.plist");
                    pCache->addSpriteFramesWithFile("middle_ani_2.plist");
                    //生成畫(huà)動(dòng)圖片列表和動(dòng)畫(huà)對(duì)象
                    CCArray* pAnimFrames = CCArray::createWithCapacity(69);
                    XAnsiString strAniName;
                    for (int i = 1; i < 70; i++)
                    {
                        strAniName.printf("light%04d.png", i);
                        pAnimFrames->addObject(pCache->spriteFrameByName(strAniName.c_str()));
                    }
                    CCAnimation* animation = CCAnimation::createWithSpriteFrames(pAnimFrames, this->m_fDuration * 2.0f/3.0f/69.0f );
                    

                    CCNode * pNode = CCNode::create(); //這個(gè)有兩個(gè)子節(jié)點(diǎn),一個(gè)是左邊交換圖片,一個(gè)是中間的動(dòng)畫(huà),用于一起做移動(dòng)的Action
                    CCSprite* pLeft = CCSprite::createWithSpriteFrameName("swap_left.png");
                    pLeft->setAnchorPoint(CCPointZero);
                    pNode->addChild(pLeft);

                    CCSprite * pMiddle = CCSprite::create();  //顯示動(dòng)畫(huà)
                    pMiddle->setAnchorPoint(CCPointZero);
                    pMiddle->setPosition(ccp(436.0f - 69.0f, 250.0f + 60.0f - 72.0f));
                    pMiddle->runAction(CCAnimate::create(animation));
                    pNode->addChild(pMiddle);

                    pNode->setAnchorPoint(ccp(0,0));
                    pNode->setPosition(stLeftBegin);
                    this->addChild(pNode,1);

                    //右邊的交換圖片
                    CCSprite* pRight = CCSprite::createWithSpriteFrameName("swap_right.png");
                    pRight->setPosition(stRightBegin);
                    pRight->setAnchorPoint(CCPointZero);
                    this->addChild(pRight, 0);

                    //定義動(dòng)作
                    
            //左邊的向右移動(dòng)活動(dòng)
                    CCMoveTo* pActionLeft = CCMoveTo::create(m_fDuration / 3, stLeftEnd);
                    //右邊的向左移動(dòng)活動(dòng)
                    CCMoveTo * pActionRight = CCMoveTo::create(m_fDuration / 3, stRightEnd);
                    //原地不動(dòng)
                    CCMoveTo* pActionLeft1 = CCMoveTo::create(m_fDuration / 3, stLeftEnd);
                    CCMoveTo * pActionRight1 = CCMoveTo::create(m_fDuration / 3, stRightEnd);
                    
                    CCMoveTo* pActionLeft2 = CCMoveTo::create(m_fDuration / 3, stLeftBegin);
                    CCMoveTo * pActionRight2 = CCMoveTo::create(m_fDuration / 3, stRightBegin);

                    m_FinishCnt = 0;
                    pNode->runAction(CCSequence::create(pActionLeft, CCCallFunc::create(this, callfunc_selector(CCTransitionGame::OnFirstActionFinish)), pActionLeft1, pActionLeft2, CCCallFunc::create(this, callfunc_selector(CCTransitionGame::LRFinish)), NULL));
                    pRight->runAction(CCSequence::create(pActionRight, pActionRight1,pActionRight2, CCCallFunc::create(this, callfunc_selector(CCTransitionGame::LRFinish)), NULL));
                }

                void CCTransitionGame::LRFinish(void)
                {
                    //所以的活動(dòng)完成后,要執(zhí)行場(chǎng)行的Finish
                    m_FinishCnt++;
                    if (m_FinishCnt >= 2)
                    {
                        CCTransitionScene::finish();
                    }
                }

                void CCTransitionGame::OnFirstActionFinish(void)
                {
                    //打開(kāi)門(mén)之前,關(guān)閉顯示第一個(gè)場(chǎng)景,顯示第二個(gè)場(chǎng)景
                    m_pInScene->setVisible(true);
                    m_pOutScene->setVisible(false);
                }

            }
            用到的資源
            /Files/zdhsoft/plist.zip 效果圖:
            posted on 2014-07-01 20:12 冬瓜 閱讀(2146) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): 原創(chuàng) 、cocos2dx
            色偷偷88欧美精品久久久| 国内精品久久国产大陆| 亚洲国产精品一区二区三区久久| 一本大道久久香蕉成人网| 伊人久久综合精品无码AV专区| AV色综合久久天堂AV色综合在 | 狠狠综合久久综合88亚洲| 97久久超碰国产精品旧版| 欧美久久天天综合香蕉伊| 亚洲AV无码久久精品蜜桃| 激情五月综合综合久久69| 色综合久久夜色精品国产| 久久不射电影网| 精品伊人久久大线蕉色首页| 亚洲国产二区三区久久| 亚洲狠狠婷婷综合久久蜜芽| 久久久久亚洲AV无码专区网站| 精品无码久久久久国产| 久久人人爽人人爽人人片av麻烦| 久久99精品久久久久久9蜜桃| 久久久无码精品亚洲日韩按摩 | 国产精品无码久久久久| 久久精品国产99久久无毒不卡 | 伊人久久大香线蕉av不卡| 国产亚洲成人久久| 久久Av无码精品人妻系列 | 久久久无码一区二区三区| 麻豆精品久久久久久久99蜜桃| 久久国产精品一区| 国产99久久九九精品无码| 99久久国产综合精品麻豆| 久久99久久99精品免视看动漫| 亚洲国产另类久久久精品小说 | 国产亚洲精品自在久久| 久久久无码精品亚洲日韩蜜臀浪潮| 亚洲人成精品久久久久| 伊人久久大香线焦AV综合影院 | 婷婷久久综合九色综合九七| 国产精品一区二区久久精品无码 | 久久精品国产久精国产思思| 人妻精品久久无码区|