【cocos2d-x入門實戰】微信飛機大戰之十三:遊戲情境過渡

來源:互聯網
上載者:User

原創作品,轉載請標明:http://blog.csdn.net/jackystudio/article/details/12082043

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/shoot_background.plist");CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/shoot.plist");

//加入copyright...//加入loadingCCSprite* loading=CCSprite::create(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("game_loading1.png"));loading->setPosition(ccp(winSize.width/2,winSize.height/2-40));this->addChild(loading);CCAnimation* animation=CCAnimation::create();//幀動畫animation->setDelayPerUnit(0.2f);animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("game_loading1.png"));animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("game_loading2.png"));animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("game_loading3.png"));animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("game_loading4.png"));CCAnimate* animate=CCAnimate::create(animation);CCRepeat* repeat=CCRepeat::create(animate,2);//重複2次CCCallFuncN* repeatdone=CCCallFuncN::create(this,callfuncN_selector(WelcomeLayer::loadingDone));//loadingDone用來轉換情境CCSequence* sequence=CCSequence::create(repeat,repeatdone);loading->runAction(sequence);

getHighestHistorySorce();

GameOverLayer* GameOverLayer::create(int passScore){GameOverLayer *pRet = new GameOverLayer();pRet->score=passScore;//score是成員變數if (pRet && pRet->init()){ pRet->autorelease(); return pRet; } else { delete pRet; pRet = NULL; return NULL; } }

CCDelayTime* delay=CCDelayTime::create(1.0f);CCScaleTo* scalebig=CCScaleTo::create(1.0f,3.0f);CCScaleTo* scalelittle=CCScaleTo::create(0.3f,2.0f);CCFiniteTimeAction* sequence=CCSequence::create(delay,scalebig,scalelittle,NULL);finalScore->runAction(sequence);

if (score>highestHistoryScore){CCUserDefault::sharedUserDefault()->setIntegerForKey("HighestScore",score);highestHistoryScore=score;CCDelayTime* delayChange=CCDelayTime::create(1.3f);CCMoveBy* moveOut=CCMoveBy::create(0.1f,ccp(0,100));CCCallFuncN* beginChange=CCCallFuncN::create(this,callfuncN_selector(GameOverLayer::beginChangeHighestScore));CCMoveBy* moveIn=CCMoveBy::create(0.1f,ccp(0,-100));CCFiniteTimeAction* sequence=CCSequence::create(delayChange,moveOut,beginChange,moveIn,NULL);highestScore->runAction(sequence);}

WelcomeScene→GameSceneGameOverScene

CCDirector::sharedDirector()->replaceScene(CCScene* pSecne);//相關資源會進行銷毀

"CCTransitionJumpZoom",    "CCTransitionProgressRadialCCW","CCTransitionProgressRadialCW","CCTransitionProgressHorizontal","CCTransitionProgressVertical","CCTransitionProgressInOut","CCTransitionProgressOutIn","CCTransitionCrossFade","TransitionPageForward","TransitionPageBackward","CCTransitionFadeTR","CCTransitionFadeBL","CCTransitionFadeUp","CCTransitionFadeDown","CCTransitionTurnOffTiles","CCTransitionSplitRows","CCTransitionSplitCols","CCTransitionFade","FadeWhiteTransition","FlipXLeftOver","FlipXRightOver","FlipYUpOver","FlipYDownOver","FlipAngularLeftOver","FlipAngularRightOver","ZoomFlipXLeftOver","ZoomFlipXRightOver","ZoomFlipYUpOver","ZoomFlipYDownOver","ZoomFlipAngularLeftOver","ZoomFlipAngularRightOver","CCTransitionShrinkGrow","CCTransitionRotoZoom","CCTransitionMoveInL","CCTransitionMoveInR","CCTransitionMoveInT","CCTransitionMoveInB","CCTransitionSlideInL","CCTransitionSlideInR","CCTransitionSlideInT","CCTransitionSlideInB",

CCLayer : public CCNode, public CCTouchDelegate, public CCAccelerometerDelegate, public CCKeypadDelegate

virtual void keyBackClicked();//對應back鍵virtual void keyMenuClicked();//對應home鍵

this->setKeypadEnabled(true);

void GameOverLayer::keyBackClicked(){CCDirector::sharedDirector()->end();//結束遊戲}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.