• <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>

            專職C++

            不能停止的腳步

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              163 Posts :: 7 Stories :: 135 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(28)

            我參與的團隊

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            cocos2dx框架已經提供了很多場景切換的類,但是一些自定義的場景切換,只有自己實現了。下面是實現的類。這里設計的分辨率是750*500.請根據實際的要求調整。
            頭文件
            #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;
                    //設置左邊的起點和終點
                    stLeftBegin.setPoint(-436.0f, -60);
                    stLeftEnd.setPoint(visibleSize.width / 2.0f + stLeftBegin.x, -60.0f);
                    //設置右邊的起點和終點
                    stRightBegin.setPoint(visibleSize.width, -60.0f);
                    stRightEnd.setPoint(visibleSize.width / 2.0f, -60.0f);
                    //加載動畫序列
                    CCSpriteFrameCache* pCache = CCSpriteFrameCache::sharedSpriteFrameCache();
                    pCache->addSpriteFramesWithFile("middle_ani_1.plist");
                    pCache->addSpriteFramesWithFile("middle_ani_2.plist");
                    //生成畫動圖片列表和動畫對象
                    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(); //這個有兩個子節點,一個是左邊交換圖片,一個是中間的動畫,用于一起做移動的Action
                    CCSprite* pLeft = CCSprite::createWithSpriteFrameName("swap_left.png");
                    pLeft->setAnchorPoint(CCPointZero);
                    pNode->addChild(pLeft);

                    CCSprite * pMiddle = CCSprite::create();  //顯示動畫
                    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);

                    //定義動作
                    
            //左邊的向右移動活動
                    CCMoveTo* pActionLeft = CCMoveTo::create(m_fDuration / 3, stLeftEnd);
                    //右邊的向左移動活動
                    CCMoveTo * pActionRight = CCMoveTo::create(m_fDuration / 3, stRightEnd);
                    //原地不動
                    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)
                {
                    //所以的活動完成后,要執行場行的Finish
                    m_FinishCnt++;
                    if (m_FinishCnt >= 2)
                    {
                        CCTransitionScene::finish();
                    }
                }

                void CCTransitionGame::OnFirstActionFinish(void)
                {
                    //打開門之前,關閉顯示第一個場景,顯示第二個場景
                    m_pInScene->setVisible(true);
                    m_pOutScene->setVisible(false);
                }

            }
            用到的資源
            /Files/zdhsoft/plist.zip 效果圖:
            posted on 2014-07-01 20:12 冬瓜 閱讀(2150) 評論(0)  編輯 收藏 引用 所屬分類: 原創cocos2dx
            武侠古典久久婷婷狼人伊人| 精品国产乱码久久久久久人妻| 欧美va久久久噜噜噜久久| 久久综合亚洲色HEZYO社区| 国产亚洲精久久久久久无码77777 国产亚洲精品久久久久秋霞 | 亚洲精品乱码久久久久久不卡| 久久91精品综合国产首页| 伊人情人综合成人久久网小说| 国产成年无码久久久久毛片| 久久本道伊人久久| 国产午夜精品久久久久九九| 亚洲精品乱码久久久久久蜜桃不卡 | 久久精品无码一区二区app| 精品国产日韩久久亚洲| 久久久不卡国产精品一区二区 | 久久精品国产亚洲7777| 色综合久久中文色婷婷| 狠狠色丁香久久综合婷婷| 97久久精品人妻人人搡人人玩 | 久久亚洲欧洲国产综合| 久久国产视屏| 久久人人爽人人人人片av| 精品久久久久成人码免费动漫| 久久久久久国产精品无码下载| 伊人久久大香线蕉综合Av| 久久精品国产亚洲综合色| 成人国内精品久久久久影院| 狠狠色婷婷综合天天久久丁香 | 国产成人久久AV免费| 国产精品伊人久久伊人电影 | 国産精品久久久久久久| 久久久久久久久久久精品尤物| 亚洲国产精品无码久久一线| 18岁日韩内射颜射午夜久久成人| 久久精品国产色蜜蜜麻豆| 狠狠色丁香久久婷婷综合_中| 国产精品久久久久9999高清| 综合久久一区二区三区| 久久久久久狠狠丁香| 嫩草伊人久久精品少妇AV| 蜜桃麻豆www久久国产精品|