// 按Start按钮开始游戏 void GameScene::gameStart( CCObject *pSender ) { if (gameState==GameOver) { // 重置游戏 hose->removeAllChildren(); hose->hoseList->removeAllObjects(); hose->onEnter(); CCDirector::sharedDirector()->resume(); CCLabelBMFont* scoreSprite =(CCLabelBMFont*)this->getChildByTag(TAG_SCORE); scoreSprite->setString("0"); this->birdReadyAction(); } gameState=Ready; // 播放音效 CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sound/lh_swooshing.ogg"); this->getChildByTag(TAG_START_BTN)->setVisible(false); this->getChildByTag(Tage_End_BTN)->setVisible(false); this->getChildByTag(TAG_OVER)->setVisible(false); // 移除分数记录 this->removeChildByTag(TAG_CURRENSCORE); this->removeChildByTag(TAG_HIGESTSCORE); this->getChildByTag(TAG_RECORD)->setVisible(false); this->getChildByTag(TAG_LOGO)->setVisible(false); this->getChildByTag(TAG_READY)->setVisible(true); this->getChildByTag(TAG_SCORE)->setVisible(true); this->getChildByTag(TAG_BIRD)->setVisible(true); this->getChildByTag(TAG_CLICK)->setVisible(true); }
void GridLayer::UpdateGridScale() { char buffer[32]; sprintf(buffer,"Scale\n%4.2f",Viewport::Instance().GetScale()); CCLabelBMFont* label = (CCLabelBMFont*)getChildByTag(TAG_LABEL_SCALE); label->setString(buffer); }
//定时执行分数自动增减 void CFScoreBoard::doAutoScore(ccTime dt){ if(scorePerSec == 0 && ((int)dt%60)!=0){ return; } this->score+=scorePerSec; int num = cun(score); for(int i = 0; i < num;i++){ int slot = pow(10.0,i); int digital = (score/slot)%10; char* buffer = new char[5]; sprintf(buffer, "%d", digital); CCLabelBMFont* pLabel =(CCLabelBMFont*) this->getChildByTag(i); if(!pLabel){ pLabel = CCLabelBMFont::labelWithString(buffer,"fonts/fonts.fnt"); CCSize labelsize = pLabel->getContentSize(); pLabel->setPosition(ccp(width-i*20,height/2)); pLabel->setTag(i); this->addChild(pLabel); }else{ pLabel->setString(buffer); } this->doChangeAnimation(scorePerSec); delete[] buffer; } }
//计时的逻辑 void TimeLayer::time_counting_down(float t) { CCLabelBMFont* timerFont = (CCLabelBMFont*) getChildByTag(15); char str[20] = {0}; counter++; sprintf(str,"Time:%d",counter); timerFont->setString(str); }
void TimeLayer::tmWaste_Func(float fTime) { ++m_nCounter; char szStr[56] = {0}; sprintf(szStr, "Time : %ds", m_nCounter); CCLabelBMFont* pFnt = (CCLabelBMFont*)getChildByTag(TIME_BM_FONT_TAG); pFnt->setString(szStr); }
void PlanLayer::changeScore(){ score+=2; char string[5] = {0}; if (score<99999) { sprintf(string, "%d", score); CCLabelBMFont *pScore = (CCLabelBMFont*) getChildByTag(30); pScore->setString(string); } }
void DailyBox::update(float delta) { FMDataManager * manager = FMDataManager::sharedManager(); int time = manager->getDailyLevelRewardTime(); if (time > 0) { setVisible(true); CCLabelBMFont * label = (CCLabelBMFont *)m_ccbNode->getChildByTag(1); int remainTime = manager->getRemainTime(time); label->setString(CCString::createWithFormat("%02d:%02d",remainTime/60,remainTime%60)->getCString()); }else{ setVisible(false); } }
BMFontInit::BMFontInit() { CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelBMFont* bmFont = new CCLabelBMFont(); bmFont->init(); bmFont->autorelease(); //CCLabelBMFont* bmFont = [CCLabelBMFont create:@"Foo" fntFile:@"arial-unicode-26.fnt"]; bmFont->setFntFile("fonts/helvetica-32.fnt"); bmFont->setString("It is working!"); this->addChild(bmFont); bmFont->setPosition(ccp(s.width/2,s.height/4*2)); }
Issue1343::Issue1343() { CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelBMFont* bmFont = new CCLabelBMFont(); bmFont->init(); bmFont->setFntFile("fonts/font-issue1343.fnt"); bmFont->setString("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"); this->addChild(bmFont); bmFont->release(); bmFont->setScale(0.3f); bmFont->setPosition(ccp(s.width/2,s.height/4*2)); }
void GamePan::updateTimer(float delta) { _curTime-=1; if(_curTime<0) { unschedule(schedule_selector(GamePan::updateTimer)); _isPlayer = !_isPlayer; changeSide(); } CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanBg); CCLabelBMFont* timerTxt = dynamic_cast<CCLabelBMFont*>(pBaseNode->getChildByTag(kTagGamePanBgTimer)); int timeStr = (int)_curTime; timerTxt->setString(Utils::itos(timeStr).c_str()); }
void FMUIWorldMap::updateGoldIapBousUI() { #ifndef BRANCH_CN return; #endif FMDataManager* manager = FMDataManager::sharedManager(); m_iapGoldBonusAni->releaseControl("Label", kProperty_StringValue); CCLabelBMFont* label = (CCLabelBMFont*)m_iapGoldBonusAni->getNodeByName("Label"); double endTime = manager->getDiscountTimeByKey(kGoldIapBouns,false); int remain = manager->getRemainTime(endTime); CCString* timeStr = manager->getTimeString(remain); label->setString(timeStr->getCString()); }
void FMUIWorldMap::updateUnlimitLifeDiscountUI() { #ifndef BRANCH_CN return; #endif FMDataManager* manager = FMDataManager::sharedManager(); CCLabelBMFont* label = NULL; m_unlimitLifeAnim->releaseControl("Label", kProperty_StringValue); label = (CCLabelBMFont*)m_unlimitLifeAnim->getNodeByName("Label"); CCString* timeStr = manager->getUnlimitLifeDiscountRestTimeStr(); label->setVisible( !(strcmp(timeStr->getCString(), "")==0) ); label->setString(timeStr->getCString()); }
void GameScene::createHighScoreLabel() { CCSize bgSize = background->getContentSize(); int highScore = CCUserDefault::sharedUserDefault()->getIntegerForKey(kHighScore, 0); const char* highScoreStr = ccsf("%d", highScore); CCLabelBMFont* highScoreLabel = (CCLabelBMFont*)background->getChildByTag(kTagHighScoreLabel); if(!highScoreLabel) { highScoreLabel = CCLabelBMFont::create(highScoreStr, kFontWhite); highScoreLabel->setPosition(ccp(bgSize.width * 0.78, bgSize.height * 0.87)); background->addChild(highScoreLabel, kZOrderLabel, kTagHighScoreLabel); } else { highScoreLabel->setString(highScoreStr); } }
void FMUIWorldMap::updateStarRewardLabel() { FMDataManager* manager = FMDataManager::sharedManager(); int idx = manager->getNextStarRewardIndex(); int maxIdx = sizeof(s_starReward) / (sizeof(int)*3) -1; idx = MIN(idx, maxIdx); int curStar = manager->getAllStarsFromSave(); int nextStar = s_starReward[idx][0]; //curStar = MIN(curStar, nextStar); char buf[16] = {0}; sprintf(buf, "%d/%d",curStar,nextStar); m_starRewardAni->releaseControl("Label", kProperty_StringValue); CCLabelBMFont* label = (CCLabelBMFont*)m_starRewardAni->getNodeByName("Label"); label->setString(buf); }
void CommonButton::setBottomString(const char * bottomStr){ if (m_label){ CCLabelBMFont * bmFont = dynamic_cast<CCLabelBMFont * >(m_pBottomlabel); if (bmFont){ bmFont->setString(bottomStr); } else { CCLabelTTF * ttf = dynamic_cast<CCLabelTTF * >(m_pBottomlabel); if (ttf) { ttf->setString(bottomStr); } } if (0 == strcmp(bottomStr, "")){ m_pBottomlabel->setVisible(false); } else { m_pBottomlabel->setVisible(true); } } }
void GamePan::doOpen() { GUIBase::doOpen(); isCheckWin=false; _isPlayer = true; addNpc(DBManager::sharedDBManager()->getActor(1)); addPlayer(DBManager::sharedDBManager()->getActor(2)); initWordList(); refreshWorldPad(); showHideConfirmPad(false); _curTime = TIME_OUT; CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanBg); CCLabelBMFont* timerTxt = dynamic_cast<CCLabelBMFont*>(pBaseNode->getChildByTag(kTagGamePanBgTimer)); int timeStr = (int)_curTime; timerTxt->setString(Utils::itos(timeStr).c_str()); changeSide(); }
// 碰撞检测 void GameScene::checkCollision() { CCSprite *bird =(CCSprite*)this->getChildByTag(TAG_BIRD); CCRect birdRect =bird->boundingBox(); if (bird->getPositionY()<ground1->boundingBox().size.height) { gameState=GameOver; score=0; this->birdFallAction(); CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sound/lh_hit.ogg"); return; } for(int i=0;i<hose->hoseList->count();i++) { CCSprite *hoseSprite =(CCSprite*)hose->hoseList->objectAtIndex(i); CCRect hoseRect =hoseSprite->boundingBox(); if (birdRect.intersectsRect(hoseRect)) { gameState=GameOver; score=0; this->birdFallAction(); CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sound/lh_hit.ogg"); break; } // 更新分数 int pPosX =hoseSprite->getPositionX()+hoseSprite->getContentSize().width*hoseSprite->getScaleX(); int birdX =bird->getPositionX()-bird->getContentSize().width*bird->getScaleX(); if (pPosX==birdX) { score++; CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sound/lh_point.ogg"); CCLabelBMFont* scoreSprite =(CCLabelBMFont*)this->getChildByTag(TAG_SCORE); CCString *strScore =CCString::createWithFormat("%d",score/2); scoreSprite->setString(strScore->m_sString.c_str()); } } updatehightestRecord(); }
void World::showLevel() { /*添加显示板*/ CCSprite* sprite = CCSprite::create("displayLevel.png"); addChild(sprite); CCLabelBMFont* label = CCLabelBMFont::create("Level", "testChinese.fnt"); sprite->addChild(label); CCString* string; if (CCUserDefault::sharedUserDefault()->getBoolForKey("ifEndlessMode")) { string = CCString::createWithFormat("Level %d", Interface::sharedInterface()->level); } else { string = CCString::createWithFormat("Level %d", Interface::sharedInterface()->level1); } label->setString(string->getCString()); label->setPosition(ccp(sprite->boundingBox().size.width * 0.5, sprite->boundingBox().size.height * 0.5)); sprite->setPosition(ccp(size.width * 0.5, size.height - sprite->boundingBox().size.height * 0.3)); sprite->setScale(0.5); sprite->setTag(tag_sprite); }
AtlasBitmapColor::AtlasBitmapColor() { CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelBMFont* label = NULL; label = CCLabelBMFont::labelWithString("Blue", "fonts/bitmapFontTest5.fnt"); label->setColor( ccBLUE ); addChild(label); label->setPosition( ccp(s.width/2, s.height/4) ); label->setAnchorPoint( ccp(0.5f, 0.5f) ); label = CCLabelBMFont::labelWithString("Red", "fonts/bitmapFontTest5.fnt"); addChild(label); label->setPosition( ccp(s.width/2, 2*s.height/4) ); label->setAnchorPoint( ccp(0.5f, 0.5f) ); label->setColor( ccRED ); label = CCLabelBMFont::labelWithString("G", "fonts/bitmapFontTest5.fnt"); addChild(label); label->setPosition( ccp(s.width/2, 3*s.height/4) ); label->setAnchorPoint( ccp(0.5f, 0.5f) ); label->setColor( ccGREEN ); label->setString("Green"); }
void WordPuzzleLayer::didCorrectCharacterSelected(CCArray* wordIdxArray, int index) { //맥스 콤보 업데이트 combo++; if (report.maxCombo < combo) { report.maxCombo = combo; } SimpleAudioEngine::sharedEngine()->playEffect("sound/main_card_popup.mp3"); char buf[20]; CCSprite* sprMultiplier; if (combo < 5) { sprMultiplier = NULL; multiplier = 1; } else if (combo < 10) { // x2 #if (defined PD_IPHONE) || (defined ANDROID_PHONE) sprMultiplier = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_double_01.png")); #else sprMultiplier = CCSprite::spriteWithFile("game/effect/game_double_01.png"); #endif multiplier = 2; } else if (combo < 20) { // x4 #if (defined PD_IPHONE) || (defined ANDROID_PHONE) sprMultiplier = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_double_02.png")); #else sprMultiplier = CCSprite::spriteWithFile("game/effect/game_double_02.png"); #endif multiplier = 4; } else if (combo < 30) { // x8 #if (defined PD_IPHONE) || (defined ANDROID_PHONE) sprMultiplier = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_double_03.png")); #else sprMultiplier = CCSprite::spriteWithFile("game/effect/game_double_03.png"); #endif multiplier = 8; } else if (combo < 50) { // x16 #if (defined PD_IPHONE) || (defined ANDROID_PHONE) sprMultiplier = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_double_04.png")); #else sprMultiplier = CCSprite::spriteWithFile("game/effect/game_double_04.png"); #endif multiplier = 16; } else { #if (defined PD_IPHONE) || (defined ANDROID_PHONE) sprMultiplier = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_double_05.png")); #else sprMultiplier = CCSprite::spriteWithFile("game/effect/game_double_05.png"); #endif multiplier = 32; } #if (defined PD_IPHONE) || (defined ANDROID_PHONE) CCSprite* label = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_up.png")); #else CCSprite* label = CCSprite::spriteWithFile("game/effect/game_up.png"); #endif label->setPosition(pointLabelPosition); this->addChild(label, 9999); if (sprMultiplier) { sprMultiplier->setAnchorPoint(ccp(0,0.5)); #if (defined PD_IPHONE) || (defined ANDROID_PHONE) sprMultiplier->setPosition(ccp(label->getContentSize().width - 5,35)); #else sprMultiplier->setPosition(ccp(175,35)); #endif label->addChild(sprMultiplier); } label->setScale(0.2); CCEaseExponentialOut * fadeout = CCEaseExponentialOut::actionWithAction( CCActionTween::actionWithDuration(1.5,"opacity",255,0) ); CCCallFuncN* callfunc = CCCallFuncN::actionWithTarget(this, callfuncN_selector(WordPuzzleLayer::onPointLabelFadeOut)); label->runAction(CCMoveBy::actionWithDuration(0.8, ccp(0,100))); label->runAction(CCEaseBounceInOut::actionWithAction(CCScaleTo::actionWithDuration(0.3,labelScaleTo))); label->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(0.7),fadeout,callfunc, NULL)); if (combo > 2) { sprintf(buf, "%dCombo",combo); CCLabelBMFont* lblCombo = (CCLabelBMFont*)getChildByTag(TAG_COMBO); CCEaseExponentialOut * fadeout = CCEaseExponentialOut::actionWithAction( CCActionTween::actionWithDuration(1.5,"opacity",255,0) ); CCCallFuncN* callfunc = CCCallFuncN::actionWithTarget(this, callfuncN_selector(WordPuzzleLayer::onPointLabelFadeOut)); if (lblCombo) { lblCombo->setString(buf); lblCombo->stopAllActions(); lblCombo->setOpacity(255); lblCombo->setPosition(comboLabelPosition); lblCombo->setScale(0.2); lblCombo->runAction(CCEaseBounceInOut::actionWithAction(CCScaleTo::actionWithDuration(0.3,labelScaleTo))); lblCombo->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(1.5),fadeout,callfunc, NULL)); } else { lblCombo = CCLabelBMFont::labelWithString(buf, "font/combo.fnt"); lblCombo->setPosition(comboLabelPosition); this->addChild(lblCombo, 9999, TAG_COMBO); lblCombo->setScale(0.2); lblCombo->runAction(CCEaseBounceInOut::actionWithAction(CCScaleTo::actionWithDuration(0.3,labelScaleTo))); lblCombo->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(1.5),fadeout,callfunc, NULL)); } } }
void Prop2GoldDialog::finish() { m_id = m_serverIface->getLoginAccountInfo()->m_id; std::stringstream ss; if(1){ //init gold has info m_goldHad = m_serverIface->getPropNumByUid(m_id,PropDef::Props_Gold); std::string goldImg; PropDef::getVirtualPropsName(PropDef::Props_Gold,goldImg); goldImg += ".png"; CCSprite *goldSprite = CCSprite::createWithSpriteFrameName(goldImg.data()); m_goldImgDele = new FSizeCCNodeDelegate(goldSprite); this->addChild(m_goldImgDele); m_goldImgDele->setLeft("parent",uilib::Left); m_goldImgDele->setTop("parent",uilib::Top); m_goldImgDele->setLeftMargin(m_edgeSize); m_goldImgDele->setTopMargin(m_edgeSize); m_goldImgDele->setLeftMargin(m_edgeSize); m_goldImgDele->setTopMargin(m_edgeSize); ss.str("");ss << "x" << m_goldHad; m_goldSprite = CCLabelBMFont::create(ss.str().data(),"fonts/font30.fnt"); FSizeCCNodeDelegate *numDele = new FSizeCCNodeDelegate(m_goldSprite); this->addChild(numDele); numDele->setLeft(m_goldImgDele->getName(),uilib::Right); numDele->setLeftMargin(2); numDele->setVertical(m_goldImgDele->getName(),0.5); } if(1){ //init confirmbutton LangDef *lang = ResourceMgr::getInstance()->getLangDef(); m_confirmButton = new BasButton(); m_confirmButton->setButtonInfo(lang->getStringById(StringEnum::SellOut),"default","buttonbg",CCSizeMake(0,0),"",getSystemFont(),24,ccWHITE); m_confirmButton->setClickCB(this,callfuncND_selector(Prop2GoldDialog::onSubmitButtonClicked)); this->addChild(m_confirmButton); m_confirmButton->setHorizontal("parent",0.5); m_confirmButton->setBottom("parent",uilib::Bottom); m_confirmButton->setBottomMargin(m_edgeSize); } if(1){ //init scroll widget m_scrollWidget = new VerScrollWidget; m_scrollWidget->setVerticalScrollPolicy(uilib::ScrollShow_Need); m_scrollWidget->setHorizontalScrollPolicy(uilib::ScrollShow_Never); this->addChild(m_scrollWidget); m_scrollWidget->setLeft("parent",uilib::Left); m_scrollWidget->setRight("parent",uilib::Right); m_scrollWidget->setTop(m_goldImgDele->getName(),uilib::Bottom); m_scrollWidget->setBottom(m_confirmButton->getName(),uilib::Top); m_scrollWidget->setBottomMargin(8); m_scrollWidget->setLeftMargin(m_edgeSize); m_scrollWidget->setRightMargin(m_edgeSize); int ruleCount = m_propRules->size(); float width = m_anchorWidth - m_edgeSize * 4; std::stringstream ss; std::string imgName; for(int i = 0;i < ruleCount;i++){ const UiMsgEv::PropExchangeRule &rule = m_propRules->at(i); if(rule.m_propType == PropDef::Props_Coin){ m_propExOn.push_back(0); m_propExLabel.push_back(0); m_propsNum.push_back(0); m_propLabel.push_back(0); continue; } BorderWidget *border = new BorderWidget; border->setTheme("default","propbg"); border->setWidth(width); border->setHeight(100); FSizeWidgetDelegate *dele = new FSizeWidgetDelegate(border,CCSizeMake(width,100)); m_scrollWidget->addFixedSizeWidget(dele); imgName = rule.m_propName + ".png"; CCSprite *propSprite = CCSprite::createWithSpriteFrameName(imgName.data()); int num = m_serverIface->getPropNumByUid(m_id,rule.m_propType); m_propsNum.push_back(num); ss.str("");ss << "x" << num; CCLabelBMFont *numSprite = CCLabelBMFont::create(ss.str().data(),"fonts/uifont24.fnt"); m_propLabel.push_back(numSprite); FSizeCCNodeDelegate *propDele = new FSizeCCNodeDelegate(propSprite); border->addChild(propDele); propDele->setLeft("parent",uilib::Left); propDele->setVertical("parent",0.5); propDele->setRightMargin(2); FSizeCCNodeDelegate *numDele = new FSizeCCNodeDelegate(numSprite); border->addChild(numDele); numDele->setLeft(propDele->getName(),uilib::Right); numDele->setVertical("parent",0.5); BasButton *incButton = new BasButton; incButton->setButtonIndex(i); incButton->setButtonInfo("","default","uiincrease",CCSizeMake(0,0)); incButton->setClickCB(this,callfuncND_selector(Prop2GoldDialog::onIncButtonClicked)); border->addChild(incButton); incButton->setRight("parent",uilib::Right); incButton->setRightMargin(2); incButton->setVertical("parent",0.5); incButton->setTouchInCB(this,callfuncND_selector(Prop2GoldDialog::onIncTouchBegin)); incButton->setTouchOutCB(this,callfuncND_selector(Prop2GoldDialog::onIncTouchEnd)); ss.str("");ss << "x" << m_goldHad; CCLabelBMFont *propNumLabel = CCLabelBMFont::create(ss.str().data(),"fonts/uifont24.fnt"); FSizeCCNodeDelegate *propNumDele = new FSizeCCNodeDelegate(propNumLabel); propNumLabel->setString("x0"); border->addChild(propNumDele); propNumDele->setRight(incButton->getName(),uilib::Left); propNumDele->setVertical("parent",0.5); m_propExOn.push_back(0); m_propExLabel.push_back(propNumLabel); BasButton *decButton = new BasButton; decButton->setButtonIndex(i); decButton->setButtonInfo("","default","uidecrease",CCSizeMake(0,0)); decButton->setClickCB(this,callfuncND_selector(Prop2GoldDialog::onDecButtonClicked)); border->addChild(decButton); decButton->setRight(propNumDele->getName(),uilib::Left); decButton->setVertical("parent",0.5); decButton->setTouchInCB(this,callfuncND_selector(Prop2GoldDialog::onDecTouchBegin)); decButton->setTouchOutCB(this,callfuncND_selector(Prop2GoldDialog::onDecTouchEnd)); } m_scrollWidget->setSpacing(20); } if(1){ std::string anim,first; anim = "uiloadinga"; first = anim; ResourceMgr::getInstance()->getFrameSpriteFirstFrame(first); m_busyAnim = new BasAnimSprite(anim,first); FSizeCCNodeDelegate *busyNode = new FSizeCCNodeDelegate(m_busyAnim); this->addChild(busyNode); busyNode->setCenterIn("parent"); m_busyAnim->setVisible(false); } }
void HelpLayer::initUI() { CCSize size = ToolsFun::sharedTools()->getSceneSize(); //背景 CCSprite * bkg = CCSprite::create("ui/shared/bkg.png"); this->addChild(bkg, -4); bkg->setPosition(size / 2); //头部 CCSprite *spBkgTop = CCSprite::create("ui/shared/top.png"); this->addChild(spBkgTop, 0); spBkgTop->setPosition(ccp(size.width / 2, size.height - spBkgTop->getContentSize().height / 2)); //金币放置最上方商城 CCSprite *coinIcon = CCSprite::create("ui/shared/coin.png"); this->addChild(coinIcon, 2, 1429); coinIcon->setPosition(ccp(280*gScaleX, size.height - 30*gScaleY)); m_coinLabel = CCLabelBMFont::create("10000000", GOLD_FONT); this->addChild(m_coinLabel, 4); m_coinLabel->setAnchorPoint(ccp(0, 0.5f)); m_coinLabel->setPosition(ccp(300*gScaleX, size.height - 25*gScaleY)); m_coinLabel->setScale(0.6F); setCoin(); CCMenu *menu = CCMenu::create(); this->addChild(menu, 10); menu->setTouchPriority(-130); menu->setPosition(CCPointZero); CCSprite *spNml = CCSprite::create("ui/shared/back.png"); CCSprite *spSel = CCSprite::create("ui/shared/back.png"); spSel->setColor(ccc3(100, 100, 100)); CCMenuItemSprite *spItem = CCMenuItemSprite::create(spNml, spSel, this, menu_selector(HelpLayer::back)); menu->addChild(spItem); spItem->setPosition(ccp(37*gScaleX, size.height - 37*gScaleY)); //show shop spNml = CCSprite::create("ui/shared/coinplus.png"); spSel = CCSprite::create("ui/shared/coinplus.png"); spSel->setColor(ccc3(100, 100, 100)); spItem = CCMenuItemSprite::create(spNml, spSel, this, menu_selector(HelpLayer::showShopLayer)); menu->addChild(spItem); spItem->setPosition(ccp(430*gScaleX, size.height - 30*gScaleY)); //初始化宠物界面 m_menu = CCMenu::create(); m_uiNode->addChild(m_menu, 2); m_uiNode->setPosition(CCPointZero); m_menu->setPosition(CCPointZero); SK::StringKey nameKey[5] = {K.ITEM_NAME0, K.ITEM_NAME1, K.ITEM_NAME2, K.ITEM_NAME3, K.ITEM_NAME4}; SK::StringKey desKey[5] = {K.ITEM_DES0, K.ITEM_DES1, K.ITEM_DES2, K.ITEM_DES3, K.ITEM_DES4}; const char *fileName[5] = {"item/item2_0.png","item/item0_0.png","item/item1_0.png", "item/item3_0.png","item4_3.png"}; for(int i = 0; i != 5; ++i) { CCSprite *petSprite = NULL; if(i ==4) { petSprite = CCSprite::createWithSpriteFrameName(fileName[i]); } else { petSprite = CCSprite::create(fileName[i]); } m_uiNode->addChild(petSprite, 1); petSprite->setPosition(ccp(120*gScaleX, 130*gScaleY)+ccp(0,180*i)); CCSprite* petDes = CCSprite::create("ui/petUI/pet_describe.png"); m_uiNode->addChild(petDes, 1); petDes->setPosition(ccp(330*gScaleX, 140*gScaleY)+ccp(0,180*i)); m_desFont[i] = CCLabelBMFont::create(gGetLanguageDesc(desKey[i]).c_str(), "font/item_des.fnt"); m_uiNode->addChild(m_desFont[i], 10); m_desFont[i]->setPosition(ccp(240*gScaleX, 130*gScaleY)+ccp(0,180*i)); m_desFont[i]->setAnchorPoint(CCPointZero); m_nameFont[i] = CCLabelBMFont::create(gGetLanguageDesc(nameKey[i]).c_str(), "font/item_des.fnt"); m_uiNode->addChild(m_nameFont[i], 10); m_nameFont[i]->setPosition(ccp(240*gScaleX, 160*gScaleY)+ccp(0,180*i)); m_nameFont[i]->setAnchorPoint(CCPointZero); CCLabelBMFont *nameLabel = m_nameFont[i]; nameLabel->setScale(0.6f); nameLabel->setString(gGetLanguageDesc(nameKey[i]).c_str()); CCLabelBMFont *desLabel = m_desFont[i]; desLabel->setScale(0.6f); desLabel->setString(gGetLanguageDesc(desKey[i]).c_str()); } }
void GameLayer::update(float dt) { if(gameSuspended) return; // MainLayer shows the background with clouds that does just scrolls but does not interact MainLayer::update(dt); CCSpriteBatchNode* batchNode = dynamic_cast<CCSpriteBatchNode*>(getChildByTag(kSpriteManager)); CCSprite* bird = dynamic_cast<CCSprite*>(batchNode->getChildByTag(kBird)); bird_position.x += bird_velocity.x * dt; // birdLookingRight/Left is used to flip the bird in the right direction i.e. direction of the velocity // so the bird does not travel backwards if(bird_velocity.x < -30.0f && birdLookingRight) { birdLookingRight = false; // what is the point of setting scaleX? bird->setScaleX(-1.0f); } else if(bird_velocity.x > 30.0f && !birdLookingRight) { birdLookingRight = true; bird->setScaleX(1.0f); } CCSize bird_size = bird->getContentSize(); float max_x = SCREEN_WIDTH + bird_size.width * 0.5f; float min_x = -bird_size.width * 0.5f; if(bird_position.x > max_x) bird_position.x = min_x; if(bird_position.x < min_x) bird_position.x = max_x; bird_velocity.y += bird_acceleration.y * dt; bird_position.y += bird_velocity.y * dt; // TODO: (fix this hack) - just set it so that every 20 frames, we decrease the percentage by 1 // when the percentage goes below zero, the healthbar is finished and finish the game // We should show some animation that the health is over. fuelInTank--; if (fuelInTank%20 == 0) { pHealthBar->setPercentage(pHealthBar->getPercentage()-1.0); if (pHealthBar->getPercentage() <= 0) { _showHighScores(); } } CCSprite* bonus = dynamic_cast<CCSprite*>(batchNode->getChildByTag(kBonusStartTag + currentBonusType)); // check if the bonus node is visible if(bonus->isVisible()) { // check if the bird and the bonus are colliding, if so, give the bird the bonus CCPoint bonus_position = bonus->getPosition(); float range = 20.0f; if(bird_position.x > bonus_position.x - range && bird_position.x < bonus_position.x + range && bird_position.y > bonus_position.y - range && bird_position.y < bonus_position.y + range) { // TODO: Our bonuses should be more rocket fuel or additional lives switch(currentBonusType) { case kBonus5: score += 5000; break; case kBonus10: score += 10000; break; case kBonus50: score += 50000; break; case kBonus100: score += 100000; break; } CCString* scoreStr = CCString::createWithFormat("%d", score); CCLabelBMFont* scoreLabel = dynamic_cast<CCLabelBMFont*>(getChildByTag(kScoreLabel)); scoreLabel->setString(scoreStr->getCString()); CCScaleTo* action1 = CCScaleTo::create(0.2f, 1.5f, 0.8f); CCScaleTo* action2 = CCScaleTo::create(0.2f, 1.0f, 1.0f); // What are CCScaleTo and CCSequence.. what do these actions do? // Likely, this just makes the bird move up very fast without it having to collide with anything CCSequence* action3 = CCSequence::create(action1, action2, action1, action2, action1, action2, NULL); scoreLabel->runAction(action3); // what does resetBonus do? _resetBonus(); _superJump(); } } int cloudTag; int platformTag; // bird collisions with platforms are detected only when the bird is falling down if(bird_velocity.y < 0) { for(platformTag = kPlatformsStartTag; platformTag < kPlatformsStartTag + K_NUM_PLATFORMS; platformTag++) { CCSprite* platform = dynamic_cast<CCSprite*>(batchNode->getChildByTag(platformTag)); CCSize platform_size = platform->getContentSize(); CCPoint platform_position = platform->getPosition(); max_x = platform_position.x - platform_size.width * 0.5f - 10; min_x = platform_position.x + platform_size.width * 0.5f + 10; float min_y = platform_position.y + (platform_size.height + bird_size.height) * 0.5f - K_PLATFORM_TOP_PADDING; // check if the bird and the platform is colliding, if so, make the bird jump if(bird_position.x > max_x && bird_position.x < min_x && bird_position.y > platform_position.y && bird_position.y < min_y) _jump(); } // The game is endless in the original version.. when the bird falls down and is longer on the screen, call the game done and // show the high score screen if(bird_position.y < - bird_size.height) _showHighScores(); } else if(bird_position.y > SCREEN_HEIGHT * 0.5f) { float delta = bird_position.y - SCREEN_HEIGHT * 0.5f; bird_position.y = SCREEN_HEIGHT * 0.5f; currentPlatformY -= delta; for(cloudTag = kCloudsStartTag; cloudTag < kCloudsStartTag + K_NUM_CLOUDS; cloudTag++) { CCSprite* cloud = dynamic_cast<CCSprite*>(batchNode->getChildByTag(cloudTag)); CCPoint position = cloud->getPosition(); position.y -= delta * cloud->getScaleY() * 0.8f; // assuming that the clouds in the background, when they have scrolled off the screen // reset them so that they will scroll in from the bottom if(position.y < -cloud->getContentSize().height * 0.5f) { currentCloudTag = cloudTag; resetCloud(); } else { cloud->setPosition(position); } } for(platformTag = kPlatformsStartTag; platformTag < kPlatformsStartTag + K_NUM_PLATFORMS; platformTag++) { CCSprite* platform = dynamic_cast<CCSprite*>(batchNode->getChildByTag(platformTag)); CCPoint position = platform->getPosition(); position = ccp(position.x, position.y - delta); // If the platform just became invisible, reset it to just above the screen if(position.y < -platform->getContentSize().height * 0.5f) { currentPlatformTag = platformTag; _resetPlatform(); } else { // If the platform is still visible, decrease its Y coordinates so it looks like the scene is scrolling platform->setPosition(position); } } CCSprite* exit = dynamic_cast<CCSprite*>(getChildByTag(kExit)); if(exit->isVisible()) { CCPoint position = exit->getPosition(); // check if the bird and the exit are colliding, if so, finish the game float range = 20.0f; if(bird_position.x > position.x - range && bird_position.x < position.x + range && bird_position.y > position.y - range && bird_position.y < position.y + range) { // TODO: (would be nice to show an animation when exiting) _showHighScores(); } position.y -= delta; if(position.y < -exit->getContentSize().height*0.5) { // the exit just passed out of the screen... you should show a "Game Over... you lose" kind of thing here // TODO: show an animation or something like... you lose!! _showHighScores(); } exit->setPosition(position); } // if the bonus was visible and is going to become invisible, reset it. if(bonus->isVisible()) { CCPoint position = bonus->getPosition(); position.y -= delta; if(position.y < -bonus->getContentSize().height * 0.5f) { _resetBonus(); } else { bonus->setPosition(position); } } score += (int) delta; CCString* scoreStr = CCString::createWithFormat("%d", score); CCLabelBMFont* scoreLabel = dynamic_cast<CCLabelBMFont*>(getChildByTag(kScoreLabel)); scoreLabel->setString(scoreStr->getCString()); } // draw the bird at its new position bird->setPosition(bird_position); }
void GameScene::step(float dt) { // CCLog("Game::step"); // Return if game suspended if(gameSuspended) return; // Get the bird sprite CCSprite *bird = (CCSprite*)getChildByTag(kBird); // Update the player x position based on velocity and delta time bird_pos.x += bird_vel.x * dt; // Flip the player based on it's x velocity and current looking direction if(bird_vel.x < -30.0f && birdLookingRight) { birdLookingRight = false; bird->setScaleX(-1.0f); } else if (bird_vel.x > 30.0f && !birdLookingRight) { birdLookingRight = true; bird->setScaleX(1.0f); } // Calculate the max and min x values for the bird // based on the screen and bird widths CCSize bird_size = bird->getContentSize(); float max_x = (float)CCDirector::sharedDirector()->getWinSize().width - bird_size.width/2; float min_x = bird_size.width/2; // Limit the bird position based on max and min values allowed if(bird_pos.x>max_x) bird_pos.x = max_x; if(bird_pos.x<min_x) bird_pos.x = min_x; // Update the bird velocity based on acceleration and time bird_vel.y += bird_acc.y * dt; // Update the bird y positin based on velocity and time bird_pos.y += bird_vel.y * dt; //////////////////////////////////////////////////////////////////////////// // Handle the bonus scoring CCSprite *bonus = (CCSprite*)getChildByTag(kBonusStartTag+currentBonusType); // If bonus is visible then see if the bird is within range to get the bonus if(bonus->isVisible() ) { CCPoint bonus_pos = bonus->getPosition(); float range = 20.0f; // If the player is within range of the bonus value then award the prize if(bird_pos.x > bonus_pos.x - range && bird_pos.x < bonus_pos.x + range && bird_pos.y > bonus_pos.y - range && bird_pos.y < bonus_pos.y + range ) { // Update score based on bonus switch(currentBonusType) { case kBonus5: score += 5000; break; case kBonus10: score += 10000; break; case kBonus50: score += 50000; break; case kBonus100: score += 100000; break; } // Build the score string to display char scoreStr[10] = {0}; sprintf(scoreStr, "%d", score); CCLabelBMFont* scoreLabel = (CCLabelBMFont*) getChildByTag(kScoreLabel); scoreLabel->setString(scoreStr); // Highlight the score with some actions to celebrate the bonus win CCActionInterval* a1 = CCScaleTo::create(0.2f, 1.5f, 0.8f); CCActionInterval* a2 = CCScaleTo::create(0.2f, 1.0f, 1.0f); scoreLabel->runAction(CCSequence::create(a1, a2, a1, a2, a1, a2, NULL)); // Reset the bonus to another platform resetBonus(); } } // If the bird has stopped moving then make it jump from the platform it is on int t; if(bird_vel.y < 0) { t = kPlatformsStartTag; // Search through all the platforms and compare the birds position with the platfor position for(t; t < kPlatformsStartTag + kNumPlatforms; t++) { CCSprite *platform = (CCSprite*)getChildByTag(t); CCSize platform_size = platform->getContentSize(); CCPoint platform_pos = platform->getPosition(); max_x = platform_pos.x - platform_size.width/2 - 10; min_x = platform_pos.x + platform_size.width/2 + 10; float min_y = platform_pos.y + (platform_size.height+bird_size.height)/2 - kPlatformTopPadding; if(bird_pos.x > max_x && bird_pos.x < min_x && bird_pos.y > platform_pos.y && bird_pos.y < min_y) { jump(); break; // Can only jump from one platform at a time to break out of the loop } } // If the bird has fallen below the screen then game over if(bird_pos.y < - bird_size.height/2) { // [self showHighscores]; <== NEED TO IMPLEMENT THE HIGHTSCORE resetBird(); // Highscore not implmented yet so just keep on going. } } else if ( bird_pos.y > ((float)CCDirector::sharedDirector()->getWinSize().height / 2)) { // If bird position is greater than the middle of the screen then move the platforms // the difference between the bird y position and middle point of the screen float delta = bird_pos.y - ((float)CCDirector::sharedDirector()->getWinSize().height / 2); // Set the bird y position to the middle of the screen bird_pos.y = (float)CCDirector::sharedDirector()->getWinSize().height / 2; // Move the current platform y by the delta amount currentPlatformY -= delta; // Move the clouds vertically and reset if necessary t = kCloudsStartTag; for (t; t < kCloudsStartTag + kNumClouds; t++) { CCSprite *cloud = (CCSprite*) getChildByTag(t); CCPoint pos = cloud->getPosition(); // Calculate new position for cloud pos.y -= delta * cloud->getScaleY() * 0.8f; // If the cloud is off the screen then need to reset this cloud else set its new position if (pos.y < -cloud->getContentSize().height/2) { currentCloudTag = t; resetCloud(); } else { // Update the new y position for the cloud. cloud->setPosition(pos); } } // Move the platforms vertically and reset if necessary t = kPlatformsStartTag; for (t; t < kPlatformsStartTag + kNumPlatforms; t++) { CCSprite *platform = (CCSprite*)getChildByTag(t); CCPoint pos = platform->getPosition(); // Calculate new position for platform pos = ccp(pos.x, pos.y - delta); // If the platform is off the screen then reset the platform else set its new position if(pos.y < - platform->getContentSize().height/2) { currentPlatformTag = t; resetPlatform(); } else { platform->setPosition(pos); } } // If the bonus is visible then adjust it's y position if(bonus->isVisible()) { CCPoint pos = bonus->getPosition(); // Calculate new position of bonus pos.y -= delta; // If the bonus is off the screen then reset the bonus else set its new position if(pos.y < -bonus->getContentSize().height/2 ) { resetBonus(); } else { bonus->setPosition(pos); } } // Update score based on how much the bird has moved score += (int)delta; // Display the new score value char scoreStr[10] = {0}; sprintf(scoreStr, "%d", score); CCLabelBMFont* scoreLabel = (CCLabelBMFont*) getChildByTag(kScoreLabel); scoreLabel->setString(scoreStr); } // Set the birds position bird->setPosition(bird_pos); }
void CNFRockerLayer::update( float delta ) { do { //得到主角 CNFProtagonist * pPro = dynamic_cast<CNFProtagonist *>(m_p3DLayer->getChildByTag(enTagProtagonist)); if (pPro!=NULL) { //得到摇杆 CCSprite * pRockerBg = dynamic_cast<CCSprite *>(getChildByTag(enTagRockerBg)); CC_BREAK_IF(pRockerBg==NULL); CCSprite * pRocker = dynamic_cast<CCSprite *>(getChildByTag(enTagRocker)); CC_BREAK_IF(pRocker==NULL); //若正在触摸 if (m_bIsTouching==true) { pRocker->setOpacity(255.f); pRockerBg->setOpacity(255.f); //触摸点与摇杆背景的距离 float fRockerDisX = m_ptTouching.x - pRockerBg->getPositionX(); float fRockerDisY = m_ptTouching.y - pRockerBg->getPositionY(); float fLen = sqrt(pow(fRockerDisX,2)+pow(fRockerDisY,2)); //触摸点与摇杆背景的角度 float fRate = (float)CC_RADIANS_TO_DEGREES( atanf(fRockerDisX/fRockerDisY) ); if(fRockerDisY<0) fRate += 180.f; else if(fRockerDisX<0) fRate += 360.f; //触摸点的实际位置 CCPoint ptRockerMoveTo; if (fLen >= m_fRockerMaxDis) fLen = m_fRockerMaxDis; ptRockerMoveTo.x = sin(fRate/180*3.1415)*fLen + pRockerBg->getPositionX(); ptRockerMoveTo.y = cos(fRate/180*3.1415)*fLen + pRockerBg->getPositionY(); //触摸点与摇杆的距离 float fDisX = ptRockerMoveTo.x - pRocker->getPositionX(); float fDisY = ptRockerMoveTo.y - pRocker->getPositionY(); float fLength = sqrt(pow(fDisX,2)+pow(fDisY,2)); //出发每次移动的条件:距离至少大于速度。 防止颤动 if (fLength > m_fRockerSpeed) { //触摸点与摇杆的角度 float fRateRocker = (float)CC_RADIANS_TO_DEGREES( atanf(fDisX/fDisY) ); if(fDisY<0) fRateRocker += 180.f; else if(fDisX<0) fRateRocker += 360.f; ptRockerMoveTo.x = sin(fRateRocker/180*3.1415)*m_fRockerSpeed + pRocker->getPositionX(); ptRockerMoveTo.y = cos(fRateRocker/180*3.1415)*m_fRockerSpeed + pRocker->getPositionY(); pRocker->setPosition(ptRockerMoveTo); } else //距离小于速度,则直接命中 { pRocker->setPosition(ptRockerMoveTo); } //主角移动 pPro->OnCtrlMoveByRotation(fRate); } //若触摸结束 else { pRocker->setOpacity(100.f); pRockerBg->setOpacity(100.f); pPro->OnCtrlStop(); //移动距离 float fDisX = pRockerBg->getPositionX() - pRocker->getPositionX(); float fDisY = pRockerBg->getPositionY() - pRocker->getPositionY(); float fLen = sqrt(pow(fDisX,2)+pow(fDisY,2)); //若距离大于速度,则移动 if (fLen > m_fRockerSpeed) { float at = (float)CC_RADIANS_TO_DEGREES( atanf(fDisX/fDisY) ); if(fDisY<0) at += 180.f; else if(fDisX<0) at += 360.f; CCPoint ptRockerMoveTo; ptRockerMoveTo.x = sin(at/180*3.1415)*m_fRockerSpeed + pRocker->getPositionX(); ptRockerMoveTo.y = cos(at/180*3.1415)*m_fRockerSpeed + pRocker->getPositionY(); pRocker->setPosition(ptRockerMoveTo); } else //若距离小雨速度,则直接命中 { pRocker->setPosition(pRockerBg->getPosition()); } } //若为副本,则执行按钮逻辑 if (m_nStageID >= _NF_TOWN_OR_BATTLE_ID_ && m_nStageID <_NF_TOWN_FB_ID_) { //得到菜单 CCMenu * pMenu = dynamic_cast<CCMenu *>(getChildByTag(enTagMenu)); CC_BREAK_IF(pMenu==NULL); //遍历按钮,同步CD for (int i=enTagBtnSkill1;i<=enTagBtnSkill5;i++) { //技能CD CCProgressTimer* pProgress = dynamic_cast<CCProgressTimer *>(getChildByTag(i+100)); CC_BREAK_IF(pProgress==NULL); //得到按钮 CCMenuItemSprite * pBtn = dynamic_cast<CCMenuItemSprite *>(pMenu->getChildByTag(i)); CC_BREAK_IF(pBtn==NULL); switch (i) { case enTagBtnSkill1: { //同步技能CD pProgress->setPercentage( 100*(float)pPro->GetSkillInfo_1().nSkill_CD_Time_Temp/(float)pPro->GetSkillInfo_1().nSkill_CD_Time ); //判断按钮是否可按 if (pPro->GetSkillInfo_1().nSkill_CD_Time_Temp == 0 && m_bIsPublicCD==false) pBtn->setEnabled(true); else pBtn->setEnabled(false); }break; case enTagBtnSkill2: { pProgress->setPercentage( 100*(float)pPro->GetSkillInfo_2().nSkill_CD_Time_Temp/(float)pPro->GetSkillInfo_2().nSkill_CD_Time ); if (pPro->GetSkillInfo_2().nSkill_CD_Time_Temp == 0 && m_bIsPublicCD==false) pBtn->setEnabled(true); else pBtn->setEnabled(false); }break; case enTagBtnSkill3: { pProgress->setPercentage( 100*(float)pPro->GetSkillInfo_3().nSkill_CD_Time_Temp/(float)pPro->GetSkillInfo_3().nSkill_CD_Time ); if (pPro->GetSkillInfo_3().nSkill_CD_Time_Temp == 0 && m_bIsPublicCD==false) pBtn->setEnabled(true); else pBtn->setEnabled(false); }break; case enTagBtnSkill4: { pProgress->setPercentage( 100*(float)pPro->GetSkillInfo_4().nSkill_CD_Time_Temp/(float)pPro->GetSkillInfo_4().nSkill_CD_Time ); if (pPro->GetSkillInfo_4().nSkill_CD_Time_Temp == 0 && m_bIsPublicCD==false) pBtn->setEnabled(true); else pBtn->setEnabled(false); }break; case enTagBtnSkill5: { pProgress->setPercentage( 100*(float)pPro->GetSkillInfo_5().nSkill_CD_Time_Temp/(float)pPro->GetSkillInfo_5().nSkill_CD_Time ); if (pPro->GetSkillInfo_5().nSkill_CD_Time_Temp == 0 && m_bIsPublicCD==false) pBtn->setEnabled(true); else pBtn->setEnabled(false); }break; } } CCProgressTimer* pProgressCom = dynamic_cast<CCProgressTimer *>(getChildByTag(enTagCommonAttackCD)); if(pProgressCom!=NULL){ pProgressCom->setPercentage( 100*pPro->GetCommonAttackCDBFB()); } CCLabelBMFont* pComonFont = dynamic_cast<CCLabelBMFont *>(getChildByTag(enTagCommonAttackFont)); if(pComonFont!=NULL){ if(pPro->GetCommonAttackStatus()!=0){ pComonFont->setString(CCString::createWithFormat("%d",pPro->GetCommonAttackStatus())->m_sString.c_str()); } } //判断是否有技能刚释放 bool bIsSkillStart = false; if (pPro->GetSkillInfo_1().nSkill_CD_Time_Temp==pPro->GetSkillInfo_1().nSkill_CD_Time-1) bIsSkillStart = true; if (pPro->GetSkillInfo_2().nSkill_CD_Time_Temp==pPro->GetSkillInfo_2().nSkill_CD_Time-1) bIsSkillStart = true; if (pPro->GetSkillInfo_3().nSkill_CD_Time_Temp==pPro->GetSkillInfo_3().nSkill_CD_Time-1) bIsSkillStart = true; if (pPro->GetSkillInfo_4().nSkill_CD_Time_Temp==pPro->GetSkillInfo_4().nSkill_CD_Time-1) bIsSkillStart = true; if (pPro->GetSkillInfo_5().nSkill_CD_Time_Temp==pPro->GetSkillInfo_5().nSkill_CD_Time-1) bIsSkillStart = true; //若有技能刚释放 if (bIsSkillStart==true) { m_bIsPublicCD = true; this->runAction(CCSequence::create(CCDelayTime::create(1.f),CCCallFunc::create(this,callfunc_selector(CNFRockerLayer::OnSkillPublicCallBack)),NULL)); for (int i=enTagBtnSkill1;i<=enTagBtnSkill5;i++) { //判断是否显示公共CD bool bIsSkillPublicCD = false; if (i==enTagBtnSkill1 && pPro->GetSkillInfo_1().nSkill_CD_Time_Temp==0) bIsSkillPublicCD = true; else if (i==enTagBtnSkill2 && pPro->GetSkillInfo_2().nSkill_CD_Time_Temp==0) bIsSkillPublicCD = true; else if (i==enTagBtnSkill3 && pPro->GetSkillInfo_3().nSkill_CD_Time_Temp==0) bIsSkillPublicCD = true; else if (i==enTagBtnSkill4 && pPro->GetSkillInfo_4().nSkill_CD_Time_Temp==0) bIsSkillPublicCD = true; else if (i==enTagBtnSkill5 && pPro->GetSkillInfo_5().nSkill_CD_Time_Temp==0) bIsSkillPublicCD = true; //若显示公共CD if (bIsSkillPublicCD==true) { //显示公共CD CCProgressTimer* pProgress = dynamic_cast<CCProgressTimer *>(getChildByTag(i+200)); CC_BREAK_IF(pProgress==NULL); pProgress->setVisible(true); pProgress->setPercentage(99.f); pProgress->runAction(CCSequence::create(CCProgressTo::create(_NF_PUBLIC_SKILL_CD_,0),NULL)); } } } } } return ; } while (false); CCLog("Fun CNFRockerLayer::update Error!"); }