void ASGame::energyBarAnimation(){ //1.显示行动力的圆形底座 CCSprite* energyBall = CCSprite::createWithSpriteFrameName("newEnergyContainer.png"); energyBall->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha)); addChild(energyBall,4); //2.行动力数量 string perStr = int2string(moveCount); CCLabelTTF* per = CCLabelTTF::create(perStr.c_str(),"Arial Rounded MT bold",32); per->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha)); addChild(per,5,1*10000000+26); //3.能量条 CCSprite* energyBarSprite = CCSprite::createWithSpriteFrameName("newEnergyBar.png"); CCProgressTimer* energyBar = CCProgressTimer::create(energyBarSprite); energyBar->setPosition(ccp(size.width*8.45/80,size.height*79.89/90+winDif*2*alpha*alpha)); energyBar->setType(kCCProgressTimerTypeRadial); energyBar->setPercentage(moveCount*20); addChild(energyBar,4,1*10000000+20); //4.攻击按钮底座 CCSprite* containerSprite = CCSprite::createWithSpriteFrameName("energyContainer.png"); CCSprite* containerSprite_s = CCSprite::createWithSpriteFrameName("energyContainer.png"); CCMenuItemSprite* energyContainer = CCMenuItemSprite::create(containerSprite,containerSprite_s,this,menu_selector(ASGame::enterFightLayer)); energyContainer->setScale(1.05); energyContainer->setPosition(ccp(size.width*179.5/200,size.height*10.25/135)); CCMenu* energyContainerMenu = CCMenu::create(energyContainer,NULL); energyContainerMenu->setPosition(CCPointZero); if (moveCount < moveToFight) energyContainerMenu->setTouchEnabled(false); addChild(energyContainerMenu,2,1*10000000+27); //5.攻击按钮充值槽 CCSprite* barSprite = CCSprite::createWithSpriteFrameName("energyBar.png"); CCProgressTimer* attackButton = CCProgressTimer::create(barSprite); attackButton->setScale(1.05); attackButton->setPosition(ccp(size.width*179.04/200,size.height*10/135)); attackButton->setType(kCCProgressTimerTypeBar); attackButton->setMidpoint(ccp(0.5, 0)); attackButton->setBarChangeRate(ccp(0, 1)); attackButton->setPercentage(100*moveCount/moveToFight); addChild(attackButton,3,1*10000000+25); //4.能量的盖子 CCSprite* energyBarCover = CCSprite::createWithSpriteFrameName("energyBarCover.png"); energyBarCover->setPosition(ccp(size.width*179.5/200,size.height*10.25/135)); energyBarCover->setOpacity(0); //addChild(energyBarCover,4,1*10000000+28); }
//****************************************************************************** // skillDecCD //****************************************************************************** void Card::skillDecCD(int cd) { CCSprite* spWhite = CCSprite::spriteWithFile("headw.png"); if (spWhite) { addChild(spWhite, 2, kToBeDeleteTag); spWhite->setPositionInPixels(CCPointMake(55 + 106*m_idx, 615)); spWhite->setIsVisible(false); spWhite->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(0.7), CCShow::action(), CCFadeIn::actionWithDuration(0.15), CCFadeOut::actionWithDuration(0.15), CCCallFunc::actionWithTarget(this, callfunc_selector(Card::delUnusedObj)), NULL)); CCProgressTimer* tmOrange = CCProgressTimer::progressWithFile("heado.png"); if (tmOrange) { addChild(tmOrange, 2, kToBeDeleteTag); tmOrange->setPositionInPixels(CCPointMake(55 + 106*m_idx, 615)); tmOrange->setType(kCCProgressTimerTypeRadialCCW); tmOrange->setPercentage(99); tmOrange->runAction(CCProgressTo::actionWithDuration(0.7, 0)); } } m_iSklCdDwn = cd; m_iCurSkillCD = MIN(m_iCurSkillCD.get(), (m_iSkillCDMax - m_iSklCdDwn)); }
bool LoadingLayer::setUpdateView() { bool isRet = false; do{ CCSprite* loadingbackimg = CCSprite::create("gmbg/loadingbg.png"); CC_BREAK_IF(!loadingbackimg); loadingbackimg->setPosition(ccp(getWinSize().width/2 + getWinOrigin().x, getWinSize().height/5 + getWinOrigin().y)); this->addChild(loadingbackimg, 1); CCSprite* loadimg = CCSprite::create("gmbg/loading.png"); CC_BREAK_IF(!loadimg); CCProgressTimer* pt = CCProgressTimer::create(loadimg); pt->setType(cocos2d::CCProgressTimerType(kCCProgressTimerTypeBar)); pt->setMidpoint(ccp(0,0.5)); pt->setBarChangeRate(ccp(1,0)); float tex = getWinSize().width/2 + getWinOrigin().x; float tey = getWinSize().height/5 + getWinOrigin().y-5; pt->setPosition(ccp(tex, tey)); pt->setPercentage(0); this->addChild(pt, 2, 1); CCProgressTo* to = CCProgressTo::create(5, 100); pt->runAction(CCRepeatForever::create(to)); isRet = true; }while(0); return isRet; }
bool wootestScene::setUpdateView() { bool isRet=false; CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); do { // 进度条背景 CCSprite* loadbackimg=CCSprite::create("lodingbg.png"); CC_BREAK_IF(!loadbackimg); loadbackimg->setPosition(ccp(visibleSize.width/2+origin.x,visibleSize.height/5+origin.y)); this->addChild(loadbackimg,2); // 进度条 CCSprite* loadimg=CCSprite::create("longding.png"); CC_BREAK_IF(!loadimg); CCProgressTimer* pt = CCProgressTimer::create(loadimg); pt->setType(kCCProgressTimerTypeBar);// 设置成横向 pt->setMidpoint(ccp(0,0)); // 设置进度条从左到右 pt->setBarChangeRate(ccp(1,0)); //重新设置锚点 float tex=visibleSize.width/2+origin.x; float tey=visibleSize.height/5+origin.y-5; pt->setPosition(ccp(tex,tey)); pt->setPercentage(0); this->addChild(pt,2,1); isRet=true; } while (0); return isRet; }
bool LoadingLayer::setUpdateView(){ bool isRet=false; do { // 设置进度条的背景图片 我们把他放到屏幕下方的1/5处 CCSprite* loadbackimg=CCSprite::create("gmbg/lodingbg.png"); CC_BREAK_IF(!loadbackimg); loadbackimg->setPosition(ccp(getWinSize().width/2+getWinOrigin().x,getWinSize().height/5+getWinOrigin().y)); this->addChild(loadbackimg,1); // 添加进度条 CCSprite* loadimg=CCSprite::create("gmbg/longding.png"); CC_BREAK_IF(!loadimg); CCProgressTimer* pt = CCProgressTimer::create(loadimg); pt->setType(kCCProgressTimerTypeBar);// 设置成横向的 //可以看作是按矩形显示效果的进度条类型 pt->setMidpoint(ccp(0,0)); // 用来设定进度条横向前进的方向从左向右或是从右向左 pt->setBarChangeRate(ccp(1,0)); //重新设置锚点 float tex=getWinSize().width/2+getWinOrigin().x; float tey=getWinSize().height/5+getWinOrigin().y-5; pt->setPosition(ccp(tex,tey)); pt->setPercentage(0); this->addChild(pt,2,1); isRet=true; } while (0); return isRet; }
bool HSShowEndurance::init() { for (int i=0; i<HSShowEndurance::S_C_ENDURANCE_COUNT; ++i) { CCString* pPanel = CCString::createWithFormat("UI_Benfangxinxiban_Naili_%d",i); HSCCSprite* pSprite = HS_FIND_UI_PANEL_SPRITE(pPanel->getCString(),"Naili_1"); pSprite->setVisible(false); CCProgressTimer* pProgress = CCProgressTimer::create(pSprite); pProgress->setType(kCCProgressTimerTypeBar); pProgress->setPosition(pSprite->getPosition()); pProgress->setMidpoint(ccp(0.5,0)); pProgress->setBarChangeRate(ccp(0,1)); i < HSShowEndurance::S_CURRENT_ENDURANCE_COUNT ? pProgress->setPercentage(100) : pProgress->setPercentage(0); pSprite->getParent()->addChild(pProgress,2000); m_enduranceMap.insert(pair<int, CCProgressTimer*>(i + 1,pProgress)); CC_SAFE_RELEASE_NULL(pPanel); } HSCCSprite* pSprite = HS_FIND_UI_PANEL_SPRITE("UI_Benfangxinxiban_Nailijishiqi","Pipeinailidiban"); m_pMaxLabel = CCLabelTTF::create("MAX", HS_FONT_HuaKang, 25, pSprite->getContentSize(), kCCTextAlignmentCenter,kCCVerticalTextAlignmentCenter); m_pMaxLabel->setAnchorPoint(HS_ANCHOR_CENTER); m_pMaxLabel->setPosition(pSprite->getAnchorPointInPoints()); m_pMaxLabel->setVisible(false); pSprite->addChild(m_pMaxLabel); this->CreateTimeLabel(); this->schedule(schedule_selector(HSShowEndurance::Updata)); return true; }
void ControllPanel::makeSkillCD(CCObject *pSender) { CCLog("makeSkillCD"); //进入CD状态 this->setMagicCD(true); //设置按钮不可用 m_pMagicItem->setIsEnabled(false); //创建技能cd样式 CCProgressTimer *cd = CCProgressTimer::progressWithFile("actor_btn_mask.png"); cd->setType(kCCProgressTimerTypeRadialCCW); cd->setPosition(m_pMagicItem->getParent()->getPosition()); cd->setPercentage(99.99f); this->addChild(cd, 1000); //技能冷却动画 CCProgressTo *to = CCProgressTo::actionWithDuration(PlayerMrg::getInstance()->getPlayer()->getPlayerSkillCd(), 0); //冷却完成之后的回调,销毁对象,同时使技能按钮可用 CCCallFuncND *callfunn = CCCallFuncND::actionWithTarget(this, callfuncND_selector(ControllPanel::endSkillCD), (void*)cd); cd->runAction(CCSequence::actions(to, callfunn, NULL)); m_lMagicCDLabel->setIsVisible(true); schedule(schedule_selector(ControllPanel::updateCountDown), 1.0f); }
void LoadingLayer::loadCallBack(CCObject* ped) { loadingNum++; CCProgressTimer* pt = (CCProgressTimer*)this->getChildByTag(1); //float now = pt->getPercentage(); pt->setPercentage(loadingNum/totalNum); if(loadingNum < totalNum){ CCLOG("loading..."); }else{ CCLOG("loading over"); } }
void CCTransitionRadialCCW::onEnter() { CCTransitionScene::onEnter(); // create a transparent color layer // in which we are going to add our rendertextures CCSize size = CCDirector::sharedDirector()->getWinSize(); // create the second render texture for outScene m_OutRT = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height); if (NULL == m_OutRT) return; m_OutRT->retain(); m_OutRT->getSprite()->setAnchorPoint(ccp(0.5f,0.5f)); m_OutRT->setPosition(ccp(size.width/2, size.height/2)); m_OutRT->setAnchorPoint(ccp(0.5f,0.5f)); // We need the texture in RenderTexture. CCProgressTimer *outNode = CCProgressTimer::progressWithTexture(m_OutRT->getSprite()->getTexture()); // but it's flipped upside down so we flip the sprite outNode->getSprite()->setFlipY(true); // fix content scale factor for radial texture CCRect rect = CCRectZero; rect.size = m_OutRT->getSprite()->getTexture()->getContentSize(); outNode->getSprite()->setTextureRect(rect, false); float scale = 1.0f / CC_CONTENT_SCALE_FACTOR(); rect.size.width *= scale; rect.size.height *= scale; outNode->setContentSize(rect.size); // Return the radial type that we want to use outNode->setType(radialType()); outNode->setPercentage(100.f); outNode->setPosition(ccp(size.width/2, size.height/2)); outNode->setAnchorPoint(ccp(0.5f,0.5f)); // create the blend action CCAction * layerAction = CCSequence::actions ( CCProgressFromTo::actionWithDuration(m_fDuration, 100.0f, 0.0f), CCEventCall::actionWithTarget(NULL, createEventHandler(this, &CCTransitionScene::_finish)), NULL ); // run the blend action outNode->runAction(layerAction); // add the layer (which contains our two rendertextures) to the scene this->addChild(outNode, 2, kSceneRadial); }
void CCTransitionRadialCCW::onEnter() { CCTransitionScene::onEnter(); // create a transparent color layer // in which we are going to add our rendertextures CCSize size = CCDirector::sharedDirector()->getWinSize(); // create the second render texture for outScene CCRenderTexture *outTexture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height); if (NULL == outTexture) { return; } outTexture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f)); outTexture->setPosition(ccp(size.width/2, size.height/2)); outTexture->setAnchorPoint(ccp(0.5f,0.5f)); // render outScene to its texturebuffer outTexture->clear(0,0,0,1); outTexture->begin(); m_pOutScene->visit(); outTexture->end(); // Since we've passed the outScene to the texture we don't need it. this->hideOutShowIn(); // We need the texture in RenderTexture. CCProgressTimer *outNode = CCProgressTimer::progressWithTexture(outTexture->getSprite()->getTexture()); // but it's flipped upside down so we flip the sprite outNode->getSprite()->setFlipY(true); // Return the radial type that we want to use outNode->setType(radialType()); outNode->setPercentage(100.f); outNode->setPosition(ccp(size.width/2, size.height/2)); outNode->setAnchorPoint(ccp(0.5f,0.5f)); // create the blend action CCAction * layerAction = CCSequence::actions ( CCProgressFromTo::actionWithDuration(m_fDuration, 100.0f, 0.0f), CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), NULL ); // run the blend action outNode->runAction(layerAction); // add the layer (which contains our two rendertextures) to the scene this->addChild(outNode, 2, kSceneRadial); }
bool BattleLayer::init() { if(!CCLayer::init()) return false; m_label = CCLabelTTF::create("第1波", "", 40); m_label->setPosition(ccp(320,800)); m_label->retain(); addChild(m_label); m_effectLabel = CCLabelTTF::create("", "", 30); m_effectLabel->setPosition(ccp(320,750)); m_effectLabel->setColor(ccc3(255,0,0)); addChild(m_effectLabel); m_guardLabel = CCLabelTTF::create("", "", 30); m_guardLabel->setPosition(ccp(320,700)); m_guardLabel->setColor(ccc3(255,255,0)); addChild(m_guardLabel); m_enemySprite = CCSprite::create("icons/0020.png"); m_enemySprite->retain(); CCSprite* hpbg = CCSprite::create("hpbar_bg.png"); CCProgressTimer* hpbar = CCProgressTimer::create(CCSprite::create("hpbar_fore.png")); hpbg->setPosition(ccp(50,100)); hpbar->setPosition(ccp(50,100)); hpbar->setType(kCCProgressTimerTypeBar); hpbar->setBarChangeRate(ccp(1,0)); hpbar->setPercentage(100); hpbar->setMidpoint(CCPointZero); hpbar->setTag(0); m_enemySprite->addChild(hpbg); m_enemySprite->addChild(hpbar); addChild(m_enemySprite,SpritezOrder::Enemy); m_cardbattleLayer = CardBattleLayer::create(); m_cardbattleLayer->retain(); m_setTrapLayer = SetTrapLayer::create(); addChild(m_setTrapLayer); m_pauseSprite = CCSprite::create("pause.png"); m_pauseSprite->setPosition(ccp(590,910)); addChild(m_pauseSprite); return true; }
CCProgressTimer* CCTransitionProgressRadialCW::progressTimerNodeWithRenderTexture(CCRenderTexture* texture) { CCSize size = CCDirector::sharedDirector()->getWinSize(); CCProgressTimer* pNode = CCProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); pNode->setType( kCCProgressTimerTypeRadial ); // Return the radial type that we want to use pNode->setReverseDirection(true); pNode->setPercentage(100); pNode->setCenterOrigin(ccp(size.width/2, size.height/2)); return pNode; }
void ASGame::HeartBar(){ //1.血条 CCSprite* heartBarSprite = CCSprite::createWithSpriteFrameName("newLifeBar.png"); CCProgressTimer* heartBar = CCProgressTimer::create(heartBarSprite); heartBar->setPosition(ccp(size.width*23.08/80,size.height*85.23/90+winDif*2*alpha*alpha)); heartBar->setType(kCCProgressTimerTypeBar); heartBar->setMidpoint(ccp(0,0.5)); heartBar->setBarChangeRate(ccp(1, 0)); heartBar->setPercentage(100); addChild(heartBar,4,1*10000000+2222); //2.生命数字 string HeartStr = int2string(shengming) + "/" + int2string(maxShengMing); CCLabelTTF* userHeartNumber= CCLabelTTF::create(HeartStr.c_str(), "Arial Rounded MT bold",25); userHeartNumber->setPosition(ccp(size.width*26/80,size.height*82/90+winDif*2*alpha*alpha)); addChild(userHeartNumber,4,1*10000000+2223); }
CCProgressTimer* CCTransitionProgressOutIn::progressTimerNodeWithRenderTexture(CCRenderTexture* texture) { CCSize size = CCDirector::sharedDirector()->getWinSize(); CCProgressTimer* pNode = CCProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); pNode->setType( kCCProgressTimerTypeBar ); pNode->setMidpoint(ccp(0.5f, 0.5f)); pNode->setBarChangeRate(ccp(1, 1)); pNode->setPercentage(100); pNode->setCenterOrigin(ccp(size.width/2, size.height/2)); return pNode; }
void BattleLayer::nextEnemyGroup() { if(m_curEnemy == 2) { Game::getInstance()->getGameScene()->setActiveLayer(GameScene::Layer_Result_Win); return; } m_curTile = m_terrain->getTileByID(0); m_enemySprite->setPosition(m_curTile->getPosition()); CCProgressTimer* bar = (CCProgressTimer*)m_enemySprite->getChildByTag(0); bar->setPercentage(100); m_curEnemy++; std::stringstream ss; ss << "第" << m_curEnemy+1 << "波"; m_label->setString(ss.str().c_str()); m_preventEnemyBuff = 0; fight(); }
void OptionLayer::skillCoolHandler(CCObject* pSender) { OptionLayer *optionLayer = global->optionLayer; UIImageView* skillView = (UIImageView*)pSender; global->hero->setAllowMove(false);//动画执行期间角色不可移动 float SumCD = 10.0f; //判断指向对象是否相等来初始化cd时间 if(optionLayer->getSkill_attack_1() == skillView){ SumCD = optionLayer->skill_SumCD_1; global->hero->RunAttackAction_1(); //执行特殊攻击1动画 }else if(optionLayer->getSkill_attack_2() == skillView){ SumCD = optionLayer->skill_SumCD_2; }else if(optionLayer->getSkill_attack_3() == skillView){ SumCD = optionLayer->skill_SumCD_3; }else if(optionLayer->getSkill_attack() == skillView){ SumCD = optionLayer->skill_SumCD_0; global->hero->RunAttackAction(); //执行普通攻击动画 }else if(optionLayer->getBlood_bottle() == skillView){ SumCD = optionLayer->blood_SumCD; }else if(optionLayer->getMagic_bottle() == skillView){ SumCD = optionLayer->magic_SumCD; } skillView->setTouchEnabled(false); //CD开始,禁止本技能使用 //初始化 cd遮罩 CCTexture2D *spriteTx = CCTextureCache::sharedTextureCache()->addImage("Skill_UI/cooling_cover.png"); CCSprite * SkillCover = CCSprite::createWithTexture(spriteTx); CCProgressTimer *skillTimer = CCProgressTimer::create(SkillCover); skillTimer->setOpacity(125); //透明度 skillTimer->setPosition(skillView->getPosition());//将进度遮罩设置在技能图标位置上 optionLayer->getSkillUI()->addChild(skillTimer); skillTimer->setType(kCCProgressTimerTypeRadial);//扇形 skillTimer->setPercentage(100); skillTimer->setReverseProgress(true); CCProgressTo* cdAction=CCProgressTo::create(SumCD, 100); CCCallFuncND* func=CCCallFuncND::create(this, callfuncND_selector(OptionLayer::allowToClick),skillView);//附带skillView参数 方便cd结束后处理 CCFiniteTimeAction* seq=CCSequence::create(cdAction,func,NULL); skillTimer->runAction(seq); }
void ASBot::energyBarAnimation(){ //1.显示行动力的圆形底座 CCSprite* energyBall = CCSprite::createWithSpriteFrameName("newEnergyContainer.png"); energyBall->setScaleX(-1); energyBall->setPosition(ccp(size.width*62.62/80,size.height*3.85/90+winDif*2*alpha*alpha)); addChild(energyBall,4); //2.行动力数量 string perStr = int2string(moveCount); CCLabelTTF* per = CCLabelTTF::create(perStr.c_str(),"Arial Rounded MT Bold",32); per->setPosition(ccp(size.width*62.3/80,size.height*3.87/90+winDif*2*alpha*alpha)); addChild(per,5,2*10000000+26); //3.能量条 CCSprite* energyBarSprite = CCSprite::createWithSpriteFrameName("newEnergyBar.png"); CCProgressTimer* energyBar = CCProgressTimer::create(energyBarSprite); energyBar->setScaleX(-1); energyBar->setPosition(ccp(size.width*71.6/80,size.height*5.89/90+winDif*2*alpha*alpha)); energyBar->setType(kCCProgressTimerTypeRadial); energyBar->setPercentage(moveCount*20); addChild(energyBar,4,2*10000000+20); }
void CCProgressTimerCreator::setAttribute(CCNode* pNode, const char* strName, const char* strValue, bool bCache) { if(bCache) mAttrMap[strName] = strValue; else { CCProgressTimer* pProgressTimer = (CCProgressTimer*)pNode; if(strcmp(strName, "file") == 0 || strcmp(strName, "plist") == 0 ) return; if(strcmp(strName, "type") == 0) pProgressTimer->setType((CCProgressTimerType)ccXmlAttrParse::toInt(strValue)); if(strcmp(strName, "percent") == 0) pProgressTimer->setPercentage(ccXmlAttrParse::toFloat(strValue)); if(strcmp(strName, "midpos") == 0) pProgressTimer->setMidpoint(ccXmlAttrParse::toPoint(strValue)); if(strcmp(strName, "rate") == 0) pProgressTimer->setBarChangeRate(ccXmlAttrParse::toPoint(strValue)); if(strcmp(strName, "reverse") == 0) pProgressTimer->setReverseProgress(ccXmlAttrParse::toBool(strValue)); if(strcmp(strName, "anchor") == 0) pProgressTimer->setAnchorPoint(ccXmlAttrParse::toPoint(strValue)); if(strcmp(strName, "color") == 0) pProgressTimer->setColor(ccXmlAttrParse::toColor3B(strValue)); else CCNodeRGBACreator::setAttribute(pNode, strName, strValue, bCache); } }
void RPGBattleMenu::onMenu(cocos2d::CCObject *pObject) { CCMenuItem *menuItem = (CCMenuItem*)pObject; SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav"); switch (menuItem->getTag()) { case kRPGBattleMenuTagSkill: { CCLog("技能"); this->hideMenu(); this->m_selectedMenuTag = kRPGBattleMenuTagSkill; CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu)); menuCancel->setPosition(ccp(43, 596)); menuCancel->setTag(kRPGBattleMenuTagCancel); menuCancel->setScale(0.75); this->addChild(menuCancel); CCTMXTiledMap *selectLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_select_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString()); selectLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - selectLayer->getContentSize().width) / 2, (CCDirector::sharedDirector()->getWinSize().height - selectLayer->getContentSize().height) / 2)); selectLayer->setTag(kRPGBattleSceneLayerTagSkillSelectDialog); ((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer); ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true); //显示title和分隔线 addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("skill_title"), 25, ccp(310, 285)); CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199); titleLab->setFontFillColor(ccc3(144, 144, 144)); CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png"); separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260)); separate->setScaleX(0.65); separate->setTag(198); selectLayer->addChild(separate); //加载技能数据 CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197); if(!tableView) { tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80)); tableView->setDirection(kCCScrollViewDirectionVertical); tableView->setPosition(CCSizeZero); tableView->setDelegate(this); tableView->setVerticalFillOrder(kCCTableViewFillTopDown); tableView->setTag(197); selectLayer->addChild(tableView); } this->m_tableItems->removeAllObjects(); string wq = ""; JsonBox::Value json; json.loadFromString(this->m_playerData->m_skill.c_str()); JsonBox::Array jsonArr = json.getArray(); for (int i = 0; i < jsonArr.size(); i++) { char* str = (char*)malloc(10 * sizeof(char)); OzgCCUtility::itoa(jsonArr[i].getInt(), str); wq.append(str); if(i + 1 < jsonArr.size()) wq.append(", "); free(str); } if((int)wq.length() > 0) { CppSQLite3Query query = this->m_db->execQuery(CCString::createWithFormat(SKILL_QUERY, wq.c_str())->getCString()); while(!query.eof()) { RPGSkillBtnData *skill = RPGSkillBtnData::create(); skill->m_dataId = query.getIntField("id"); skill->m_name = query.getStringField("name_cns"); skill->m_MP = query.getIntField("mp"); skill->m_skillAttack = query.getIntField("skill_attack"); skill->m_type = query.getIntField("type"); skill->m_attr = query.getIntField("attr"); skill->m_enabled = true; //不能使用技能的情况 if(this->m_playerData->m_MP <= 0 || this->m_playerData->m_HP <= 0) skill->m_enabled = false; else if(this->m_playerData->m_MP < skill->m_MP) skill->m_enabled = false; this->m_tableItems->addObject(skill); query.nextRow(); } query.finalize(); } tableView->reloadData(); //加载技能数据 end ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false); } break; case kRPGBattleMenuTagItems: { CCLog("道具"); this->hideMenu(); this->m_selectedMenuTag = kRPGBattleMenuTagItems; CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu)); menuCancel->setPosition(ccp(43, 596)); menuCancel->setTag(kRPGBattleMenuTagCancel); menuCancel->setScale(0.75); this->addChild(menuCancel); CCTMXTiledMap *selectLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_select_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString()); selectLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - selectLayer->getContentSize().width) / 2, (CCDirector::sharedDirector()->getWinSize().height - selectLayer->getContentSize().height) / 2)); selectLayer->setTag(kRPGBattleSceneLayerTagItemsSelectDialog); ((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer); ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true); //显示title和分隔线 addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("items_title"), 25, ccp(310, 285)); CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199); titleLab->setFontFillColor(ccc3(144, 144, 144)); CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png"); separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260)); separate->setScaleX(0.65); separate->setTag(198); selectLayer->addChild(separate); //加载道具数据 CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197); if(!tableView) { tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80)); tableView->setDirection(kCCScrollViewDirectionVertical); tableView->setPosition(CCSizeZero); tableView->setDelegate(this); tableView->setVerticalFillOrder(kCCTableViewFillTopDown); tableView->setTag(197); selectLayer->addChild(tableView); } this->m_tableItems->removeAllObjects(); CCArray *existingItems = ((RPGBattleSceneLayer*)this->m_parentNode)->m_existingItems; for (int i = 0; i < existingItems->count(); i++) this->m_tableItems->addObject(existingItems->objectAtIndex(i)); tableView->reloadData(); //加载道具数据 end ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false); } break; case kRPGBattleMenuTagEscape: { // CCLog("逃跑"); float success = CCRANDOM_0_1(); if(success >= 0.0 && success <= 0.5) { // CCLog("逃跑成功"); this->setEnabled(false); this->removeFromParentAndCleanup(true); ((RPGBattleSceneLayer*)this->m_parentNode)->goToMap(); } else { ((RPGBattleSceneLayer*)this->m_parentNode)->showMsg((CCString*)this->m_stringList->objectForKey("escape_fail")); //重置进度条 this->m_playerData->m_progress = 0.0; CCProgressTimer *battleProgress = (CCProgressTimer*)this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagPlayerProgress + this->m_playerData->m_dataId); battleProgress->setPercentage(this->m_playerData->m_progress); ((RPGBattleSceneLayer*)this->m_parentNode)->scheduleUpdate(); CCTMXTiledMap *bgLayer = (CCTMXTiledMap*)this->m_parentNode->getChildByTag(kRPGBattleMenuTagBg); bgLayer->removeFromParentAndCleanup(true); this->removeFromParentAndCleanup(true); } } break; case kRPGBattleMenuTagCancel: { // CCLog("取消"); this->showMenu(); CCMenuItem *menuCancel = (CCMenuItem*)this->getChildByTag(kRPGBattleMenuTagCancel); menuCancel->removeFromParentAndCleanup(true); switch (this->m_selectedMenuTag) { case kRPGBattleMenuTagAttack: CCLog("取消攻击"); ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false); ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected(); break; case kRPGBattleMenuTagSkill: CCLog("取消技能列表"); if(((RPGBattleSceneLayer*)this->m_parentNode)->getChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog)) ((RPGBattleSceneLayer*)this->m_parentNode)->removeChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog, true); ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false); ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected(); break; case kRPGBattleMenuTagItems: CCLog("取消道具列表"); if(((RPGBattleSceneLayer*)this->m_parentNode)->getChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog)) ((RPGBattleSceneLayer*)this->m_parentNode)->removeChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog, true); ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false); ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected(); break; // default: // break; } } break; case kRPGBattleMenuTagCancel2: { //这个选择了一个技能或道具后,到了选择目标对象的一步,使用到的取消按钮 CCMenuItemSprite *menuCancel = (CCMenuItemSprite*)this->getChildByTag(kRPGBattleMenuTagCancel); menuCancel->setVisible(true); CCMenuItemSprite *menuCancel2 = (CCMenuItemSprite*)this->getChildByTag(kRPGBattleMenuTagCancel2); menuCancel2->removeFromParentAndCleanup(true); if(this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog)) this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagItemsSelectDialog)->setVisible(true); if(this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog)) this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagSkillSelectDialog)->setVisible(true); ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false); ((RPGBattleSceneLayer*)this->m_parentNode)->cancelAllSelected(); } break; default: { CCLog("攻击"); this->hideMenu(); this->m_selectedMenuTag = kRPGBattleMenuTagAttack; CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu)); menuCancel->setPosition(ccp(43, 596)); menuCancel->setTag(kRPGBattleMenuTagCancel); menuCancel->setScale(0.75); this->addChild(menuCancel); ((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true); } break; } }
void BattleLayer::updateEnemyHpBar() { CCProgressTimer* bar = (CCProgressTimer*)m_enemySprite->getChildByTag(0); bar->setPercentage(m_enemycards[m_curEnemy]->getHPPercentage() * 100); }
bool FrontCoverLayer::init() { bool bRet = false; do { CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); CCSprite* pSprite = CCSprite::create("frontCover.png"); // position the sprite on the center of the screen float scaleX = visibleSize.width/pSprite->getTexture()->getPixelsWide(); float scaleY = visibleSize.height/pSprite->getTexture()->getPixelsHigh(); float scale = (scaleX > scaleY) ? scaleX : scaleY; pSprite->setScaleX(scale); pSprite->setScaleY(scale); pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); this->addChild(pSprite, 0); //SkeletonAnimRcsManager::getInstance()->LoadOneRoleRcsOnly(201); SkeletonAnimRcsManager::getInstance()->LoadOneRoleRcsOnly(202); SkeletonAnimRcsManager::getInstance()->LoadOneRoleRcsOnly(203); EffectSprite* effect1 = ParticleManager::Get()->createEffectSprite(202,""); if(effect1) { effect1->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); effect1->getRoot()->setScale(scale); this->addChild(effect1, 1); effect1->SetAnim(kType_Play,1,true); } //effect1 = ParticleManager::Get()->createEffectSprite(201,""); //if(effect1) //{ // effect1->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); // effect1->getRoot()->setScale(scale); // this->addChild(effect1, 1); // effect1->SetAnim(kType_Play,1,true); //} effect1 = ParticleManager::Get()->createEffectSprite(203,""); if(effect1) { effect1->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); effect1->getRoot()->setScale(scale); this->addChild(effect1, 1); effect1->SetAnim(kType_Play,1,true); } CCSprite* spriteFrame = CCSprite::create("frontCoverFrame.png"); spriteFrame->setScaleX(scale); spriteFrame->setScaleY(scale); spriteFrame->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); this->addChild(spriteFrame, 2); schedule(schedule_selector(FrontCoverLayer::update), 1); //ASprite *as = AspriteManager::getInstance()->getAsprite(KUI_BIN); //CCPoint pt; //CCSprite* bar = as->getSpriteFromFrame_Middle(map_ui_FRAME_EQUIPMENT_BAR_EXP, 0, pt); //CCSprite* barFrame = as->getSpriteFromFrame_Middle(map_ui_FRAME_EQUIPMENT_FRAME_EXP, 0, pt); CCSprite* barFrame = CCSprite::create("load0001.png"); barFrame->setPosition(ccp(visibleSize.width/2, visibleSize.height/6)); addChild(barFrame); CCSprite* sp = CCSprite::create("load0002.png"); CCProgressTimer *progressBar = CCProgressTimer::create(sp); barFrame->addChild(progressBar,-1); progressBar->setPosition(ccp(6, barFrame->getContentSize().height/2-4)); progressBar->setType(kCCProgressTimerTypeBar); progressBar->setAnchorPoint(ccp(0,0)); progressBar->setMidpoint(ccp(0,0)); progressBar->setBarChangeRate(ccp(1,0)); progressBar->setPercentage(0.0f); _downloadTTF = CCLabelTTF::create("0%", KJLinXin, 15); _downloadTTF->setColor(ccORANGE); barFrame->addChild(_downloadTTF); _downloadTTF->setPosition(ccp(barFrame->getContentSize().width/2,barFrame->getContentSize().height/2)); _downloadBar = progressBar; //_downloadBar->retain(); _barFrame = barFrame; _barFrame->retain(); GameResourceManager::sharedManager()->updateResource(); GameAudioManager::sharedManager()->playLoadingBGM(); const char* vision = LuaTinkerManager::Get()->callLuaFunc<char *>("Script/main.lua", "getVisionNum"); m_visionLabel = CCLabelTTF::create(vision,KJLinXin,20); if(m_visionLabel) { float scale = UIManager::sharedManager()->getScaleFactor(); m_visionLabel->setColor(ccWHITE); m_visionLabel->setScale(scale); addChild(m_visionLabel); m_visionLabel->setPosition(ccp(visibleSize.width -m_visionLabel->getContentSize().width/2, visibleSize.height -m_visionLabel->getContentSize().height/2)); } m_layout = UIManager::sharedManager()->CreateUILayoutFromFile("UIplist/splashUI.plist", this, "SplashLayout"); UIManager::sharedManager()->RegisterMenuHandler("SplashLayout","FrontCoverLayer::menuLoginGameCallback", menu_selector(FrontCoverLayer::menuLoginGameCallback), this); UIManager::sharedManager()->RegisterMenuHandler("SplashLayout","FrontCoverLayer::onClickedMoreSever", menu_selector(FrontCoverLayer::onClickedMoreSever), this); UIManager::sharedManager()->RegisterMenuHandler("SplashLayout","FrontCoverLayer::onCLickedSeverCloseBt", menu_selector(FrontCoverLayer::onCLickedSeverCloseBt), this); UIManager::sharedManager()->RegisterMenuHandler("SplashLayout","FrontCoverLayer::onClickedLatestSever", menu_selector(FrontCoverLayer::onClickedLatestSever), this); if(m_layout) { m_severScrollPage = m_layout->FindChildObjectByName<UIScrollPage>("severScrollPage"); setLastServerLabel(); m_layout->setVisible(false); } /// response to keyboard this->setKeypadEnabled(true); bRet = true; }while (0); return bRet; }
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!"); }
//碰撞检测 void game_bj::auto_pz(char id) { CCSprite *sprinte_11 = (CCSprite*)getChildByTag(11); CCSprite *sprinte_12 = (CCSprite*)getChildByTag(12); CCSprite *sprinte_13 = (CCSprite*)getChildByTag(13); CCSprite *sprinte_14 = (CCSprite*)getChildByTag(14); CCSprite *sprinte_15 = (CCSprite*)getChildByTag(15); CCSprite *sprinte_11_a = (CCSprite*)getChildByTag(21); CCSprite *sprinte_12_a = (CCSprite*)getChildByTag(22); CCSprite *sprinte_13_a = (CCSprite*)getChildByTag(23); CCSprite *sprinte_14_a = (CCSprite*)getChildByTag(24); CCSprite *sprinte_15_a = (CCSprite*)getChildByTag(25); CCSprite *sprinte_11_b = (CCSprite*)getChildByTag(31); CCSprite *sprinte_12_b = (CCSprite*)getChildByTag(32); CCSprite *sprinte_13_b = (CCSprite*)getChildByTag(33); CCSprite *sprinte_14_b = (CCSprite*)getChildByTag(34); CCSprite *sprinte_15_b = (CCSprite*)getChildByTag(35); CCSprite *sprinte_11_y_a = (CCSprite*)getChildByTag(41); CCSprite *sprinte_12_y_a = (CCSprite*)getChildByTag(42); CCSprite *sprinte_13_y_a = (CCSprite*)getChildByTag(43); CCSprite *sprinte_14_y_a = (CCSprite*)getChildByTag(44); CCSprite *sprinte_15_y_a = (CCSprite*)getChildByTag(45); CCSprite *sprinte_11_y_b = (CCSprite*)getChildByTag(51); CCSprite *sprinte_12_y_b = (CCSprite*)getChildByTag(52); CCSprite *sprinte_13_y_b = (CCSprite*)getChildByTag(53); CCSprite *sprinte_14_y_b = (CCSprite*)getChildByTag(54); CCSprite *sprinte_15_y_b = (CCSprite*)getChildByTag(55); for (int ii = 101; ii<=112; ii++) { CCSprite *sprinte_xxx = (CCSprite*)getChildByTag(ii); if(sprinte_xxx) { // CCLOG("44"); bool ret_1 = false; bool ret_2 = false; bool ret_3 = false; bool ret_4 = false; bool ret_5 = false; if(sprinte_11) { ret_1 = CCRect::CCRectIntersectsRect(sprinte_xxx->boundingBox(), sprinte_11->boundingBox()); } if(sprinte_12) { ret_2 = CCRect::CCRectIntersectsRect(sprinte_xxx->boundingBox(), sprinte_12->boundingBox()); } if(sprinte_13) { ret_3 = CCRect::CCRectIntersectsRect(sprinte_xxx->boundingBox(), sprinte_13->boundingBox()); } if(sprinte_14) { ret_4 = CCRect::CCRectIntersectsRect(sprinte_xxx->boundingBox(), sprinte_14->boundingBox()); } if(sprinte_15) { ret_5 = CCRect::CCRectIntersectsRect(sprinte_xxx->boundingBox(), sprinte_15->boundingBox()); } if(ret_1) { CCPoint point = sprinte_11->getPosition(); // CCLOG("1"); // this->removeChild(sprinte_11, true); // this->removeChild(sprinte_11_a, true); // this->removeChild(sprinte_11_b, true); // this->removeChild(sprinte_11_y_a, true); // this->removeChild(sprinte_11_y_b, true); int new_value_11 = game_bj::e_11-10; if(new_value_11 <= 0) { this->removeChild(sprinte_11, true); this->removeChild(sprinte_11_a, true); this->removeChild(sprinte_11_b, true); this->removeChild(sprinte_11_y_a, true); this->removeChild(sprinte_11_y_b, true); CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(71); if(pt) { this->removeChild(pt, true); } game_bj::e_11 = 100; } CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(71); if(pt) { pt->setPercentage(game_bj::e_11); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value_11); pt->runAction(to); game_bj::e_11 = game_bj::e_11-10; } else { CCSprite *sprinte_11 = (CCSprite*)getChildByTag(11); if(sprinte_11) { CCProgressTimer *pt = CCProgressTimer::progressWithSprite(CCSprite::create("hatchling_exp_02.png")); pt->setPercentage(game_bj::e_11); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); pt->setScale(0.4); pt->setMidpoint(ccp(0,0)); pt->setBarChangeRate(ccp(1,0)); this->addChild(pt,0,71); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value_11); pt->runAction(to); game_bj::e_11 = game_bj::e_11-10; } } CCSprite *item_gb = new CCSprite(); item_gb->initWithFile("item_coin.png"); item_gb->setPosition( ccp(point.x, point.y) ); item_gb->setScale(game_bj::scale); this->addChild(item_gb, 0,61); CCJumpTo* mJumpTo = CCJumpTo::actionWithDuration(2.0f, ccp(280, 1), 230.0f, 1); CCActionInterval* seq_aa = (CCActionInterval*)(CCSequence::actions(mJumpTo, NULL)); item_gb->runAction(seq_aa); } if(ret_2) { CCPoint point = sprinte_12->getPosition(); CCLOG("2"); this->removeChild(sprinte_12, true); this->removeChild(sprinte_12_a, true); this->removeChild(sprinte_12_b, true); this->removeChild(sprinte_12_y_a, true); this->removeChild(sprinte_12_y_b, true); CCSprite *item_gb = new CCSprite(); item_gb->initWithFile("item_coin.png"); item_gb->setPosition( ccp(point.x, point.y) ); item_gb->setScale(game_bj::scale); this->addChild(item_gb, 0,62); CCJumpTo* mJumpTo = CCJumpTo::actionWithDuration(2.0f, ccp(280, 1), 230.0f, 1); CCActionInterval* seq_aa = (CCActionInterval*)(CCSequence::actions(mJumpTo, NULL)); item_gb->runAction(seq_aa); } if(ret_3) { CCPoint point = sprinte_13->getPosition(); int new_value = game_bj::e_13-10; CCLOG("%i",new_value); if(new_value <= 0) { this->removeChild(sprinte_13, true); this->removeChild(sprinte_13_a, true); this->removeChild(sprinte_13_b, true); this->removeChild(sprinte_13_y_a, true); this->removeChild(sprinte_13_y_b, true); CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(73); if(pt) { this->removeChild(pt, true); } game_bj::e_13 = 100; } CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(73); if(pt) { pt->setPercentage(game_bj::e_13); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value); pt->runAction(to); game_bj::e_13 = game_bj::e_13-10; } else { CCSprite *sprinte_13 = (CCSprite*)getChildByTag(13); if(sprinte_13) { CCProgressTimer *pt = CCProgressTimer::progressWithSprite(CCSprite::create("hatchling_exp_02.png")); pt->setPercentage(game_bj::e_13); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); pt->setScale(0.4); pt->setMidpoint(ccp(0,0)); pt->setBarChangeRate(ccp(1,0)); this->addChild(pt,0,73); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value); pt->runAction(to); game_bj::e_13 = game_bj::e_13-10; } } CCSprite *item_gb = new CCSprite(); item_gb->initWithFile("item_coin.png"); item_gb->setPosition( ccp(point.x, point.y) ); item_gb->setScale(game_bj::scale); this->addChild(item_gb, 0,63); CCJumpTo* mJumpTo = CCJumpTo::actionWithDuration(2.0f, ccp(280, 1), 230.0f, 1); CCActionInterval* seq_aa = (CCActionInterval*)(CCSequence::actions(mJumpTo, NULL)); item_gb->runAction(seq_aa); } if(ret_4) { CCPoint point = sprinte_14->getPosition(); // CCLOG("4"); // this->removeChild(sprinte_14, true); // this->removeChild(sprinte_14_a, true); // this->removeChild(sprinte_14_b, true); // this->removeChild(sprinte_14_y_a, true); // this->removeChild(sprinte_14_y_b, true); int new_value_14 = game_bj::e_14-10; if(new_value_14 <= 0) { this->removeChild(sprinte_14, true); this->removeChild(sprinte_14_a, true); this->removeChild(sprinte_14_b, true); this->removeChild(sprinte_14_y_a, true); this->removeChild(sprinte_14_y_b, true); CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(74); if(pt) { this->removeChild(pt, true); } game_bj::e_14 = 100; } CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(74); if(pt) { pt->setPercentage(game_bj::e_14); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value_14); pt->runAction(to); game_bj::e_14 = game_bj::e_14-10; } else { CCSprite *sprinte_14 = (CCSprite*)getChildByTag(14); if(sprinte_14) { CCProgressTimer *pt = CCProgressTimer::progressWithSprite(CCSprite::create("hatchling_exp_02.png")); pt->setPercentage(game_bj::e_14); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); pt->setScale(0.4); pt->setMidpoint(ccp(0,0)); pt->setBarChangeRate(ccp(1,0)); this->addChild(pt,0,74); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value_14); pt->runAction(to); game_bj::e_14 = game_bj::e_14-10; } } CCSprite *item_gb = new CCSprite(); item_gb->initWithFile("item_coin.png"); item_gb->setPosition( ccp(point.x, point.y) ); item_gb->setScale(game_bj::scale); this->addChild(item_gb, 0,64); CCJumpTo* mJumpTo = CCJumpTo::actionWithDuration(2.0f, ccp(280, 1), 230.0f, 1); CCActionInterval* seq_aa = (CCActionInterval*)(CCSequence::actions(mJumpTo, NULL)); item_gb->runAction(seq_aa); } if(ret_5) { CCPoint point = sprinte_15->getPosition(); CCLOG("5"); this->removeChild(sprinte_15, true); this->removeChild(sprinte_15_a, true); this->removeChild(sprinte_15_b, true); this->removeChild(sprinte_15_y_a, true); this->removeChild(sprinte_15_y_b, true); CCSprite *item_gb = new CCSprite(); item_gb->initWithFile("item_coin.png"); item_gb->setPosition( ccp(130, 340) ); item_gb->setScale(game_bj::scale); this->addChild(item_gb, 0,64); CCJumpTo* mJumpTo = CCJumpTo::actionWithDuration(2.0f, ccp(280, 1), 230.0f, 1); CCActionInterval* seq_aa = (CCActionInterval*)(CCSequence::actions(mJumpTo, NULL)); item_gb->runAction(seq_aa); } CCPoint a = sprinte_xxx->getPosition(); if( a.y>=477) { this->removeChild(sprinte_xxx, true); if(ii==101) { game_bj::a=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("a", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==102) { game_bj::b=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("b", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==103) { game_bj::c=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("c", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==104) { game_bj::d=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("d", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==105) { game_bj::e=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("e", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==106) { game_bj::f=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("f", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==107) { game_bj::g=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("g", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==108) { game_bj::h=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("h", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==109) { game_bj::i=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("i", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==110) { game_bj::j=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("j", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==111) { game_bj::k=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("k", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==112) { game_bj::l=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("l", 1); // CCUserDefault::sharedUserDefault()->flush(); } } } } for (int i=11; i<=15; i++) { CCSprite *sprinte_yyy = (CCSprite*)getChildByTag(i); CCSprite *sprinte_yyy_a = (CCSprite*)getChildByTag(i+10); CCSprite *sprinte_yyy_b = (CCSprite*)getChildByTag(i+20); CCSprite *sprinte_yyy_y_a = (CCSprite*)getChildByTag(i+30); CCSprite *sprinte_yyy_y_b = (CCSprite*)getChildByTag(i+40); CCSprite *sprinte_item_gb = (CCSprite*)getChildByTag(i+50); CCSprite *sprinte_pt = (CCSprite*)getChildByTag(i+60); if(sprinte_yyy) { CCPoint a = sprinte_yyy->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_yyy, true); } } if(sprinte_yyy_a) { CCPoint a = sprinte_yyy_a->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_yyy_a, true); } } if(sprinte_yyy_b) { CCPoint a = sprinte_yyy_b->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_yyy_b, true); } } if(sprinte_yyy_y_a) { CCPoint a = sprinte_yyy_y_a->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_yyy_y_a, true); } } if(sprinte_yyy_y_b) { CCPoint a = sprinte_yyy_y_b->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_yyy_y_b, true); } } if(sprinte_item_gb) { CCPoint a = sprinte_item_gb->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_item_gb, true); } } if(sprinte_pt) { CCPoint a = sprinte_pt->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_pt, true); game_bj::e_11 = 100; game_bj::e_12 = 100; game_bj::e_13 = 100; game_bj::e_14 = 100; game_bj::e_15 = 100; } } } }
bool MonsterLayer::init() { CCAssert(CCLayer::init(),"CCLayer init failed!"); int iPlayerCount = m_data->size(); this->setTouchEnabled(true); CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,1,false); float fScreenWidth = CCDirector::sharedDirector()->getVisibleSize().width; float fScreenHeight = CCDirector::sharedDirector()->getVisibleSize().height; for (int i = 0;i<iPlayerCount;++i) { string name = m_data->at(i)->getName(); char pName[MAX_FILE_PATH_LENGTH]; #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) GBKToUTF(name); #endif sprintf(pName,MONSTER_DIR_PATH,name.c_str()); CCSprite *pSprite = CCSprite::create(pName); CCAssert(pSprite,"Get Monster sprite failed!"); float fPlayerWidth = pSprite->getContentSize().width; float fPlayerHeight = pSprite->getContentSize().height; float xpos = fScreenWidth*0.5+(i-iPlayerCount*0.5+0.5)*fPlayerWidth; float ypos = fScreenHeight*0.6; pSprite->setPosition(ccp(xpos,ypos)); pSprite->setOpacity(0); addChild(pSprite,0,i); m_monsters->addObject(pSprite); m_originalPos.insert(make_pair(i,ccp(xpos,ypos))); //HP Bar CCProgressTimer *hpBarTimer = CCProgressTimer::create(CCSprite::create(MONSTER_HP_BAR_PATH)); hpBarTimer->setType(kCCProgressTimerTypeBar); hpBarTimer->setMidpoint(ccp(0,0)); hpBarTimer->setPercentage(100); hpBarTimer->setBarChangeRate(ccp(1,0)); hpBarTimer->setPosition(ccp(pSprite->getPositionX(), pSprite->getPositionY() + fPlayerHeight*0.5 + hpBarTimer->getContentSize().height*0.5)); hpBarTimer->setOpacity(0); addChild(hpBarTimer,1,iPlayerCount+i); } //Damage number m_pFont = CCLabelBMFont::create("0",FONT_PATH); m_pFont->setColor(ccYELLOW); m_pFont->setOpacity(0); addChild(m_pFont,4); //Magic matrix tag m_magicTag = CCSprite::create(MAGIC_BTN_PATH); m_magicTag->setOpacity(0); m_magicTag->setPosition(ccp(750,550)); addChild(m_magicTag); m_magicPointer = CCSprite::create(MAGIC_UNAVA_PATH); m_magicPointer->setOpacity(0); m_magicPointer->setPosition(ccp(750,550)); addChild(m_magicPointer); m_magicAva = CCTextureCache::sharedTextureCache()->addImage(MAGIC_AVA_PATH); m_magicUnava = CCTextureCache::sharedTextureCache()->addImage(MAGIC_UNAVA_PATH); m_longHPBar = CCProgressTimer::create(CCSprite::create(LONG_HP_BAR)); m_longHPBar->setType(kCCProgressTimerTypeBar); m_longHPBar->setMidpoint(ccp(0,0)); m_longHPBar->setPercentage(100); m_longHPBar->setBarChangeRate(ccp(1,0)); m_longHPBar->setOpacity(0); m_longHPBar->setPosition(ccp(fScreenWidth*0.5,fScreenHeight*0.3)); addChild(m_longHPBar,2); m_timeBarEmpty = CCSprite::create(TIME_BAR_EMPTY); m_timeBarEmpty->setOpacity(0); m_timeBarEmpty->setPosition(ccp(fScreenWidth*0.5,fScreenHeight*0.7)); addChild(m_timeBarEmpty,2); m_timeBarFull = CCProgressTimer::create(CCSprite::create(TIME_BAR_FULL)); m_timeBarFull->setType(kCCProgressTimerTypeBar); m_timeBarFull->setMidpoint(ccp(0,0)); m_timeBarFull->setPercentage(100); m_timeBarFull->setBarChangeRate(ccp(1,0)); m_timeBarFull->setOpacity(0); m_timeBarFull->setPosition(ccp(fScreenWidth*0.5,fScreenHeight*0.7)); addChild(m_timeBarFull,2); CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache(); cache->addSpriteFramesWithFile(BUBBLE_PLIST_PATH,BUBBLE_TEXTURE_PATH); return true; }
bool CNFRockerLayer::InitLayer(CNF3DWorldLayer * pLayer,int nStageID) { do { //初始化父类 CC_BREAK_IF(CCLayerColor::initWithColor(ccc4(255,0,0,50))==false); //注册 CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,-1,false); //设置层大小 setContentSize(CCSizeMake(200,200));//(CCSizeMake(SCREEN_WIDTH*0.5f,SCREEN_HEIGHT)); m_p3DLayer = pLayer; m_bIsTouching = false; m_bIsPublicCD = false; m_fRockerSpeed = _NF_ROCKER_SPEED_; //摇杆的移动速度 m_fRockerMaxDis = _NF_ROCKER_MAX_DIS_; //摇杆最大偏移量 m_nStageID = nStageID; //主角技能ID CNFProtagonist * pPro = dynamic_cast<CNFProtagonist *>(pLayer->getChildByTag(enTagProtagonist)); CC_BREAK_IF(pPro==NULL); m_nSkill_1_ID = pPro->GetSkillInfo_1().nSkill_SkillItemID; m_nSkill_2_ID = pPro->GetSkillInfo_2().nSkill_SkillItemID; m_nSkill_3_ID = pPro->GetSkillInfo_3().nSkill_SkillItemID; m_nSkill_4_ID = pPro->GetSkillInfo_4().nSkill_SkillItemID; m_nSkill_5_ID = pPro->GetSkillInfo_5().nSkill_SkillItemID; //创建摇杆背景 CCSprite * pRockerBg = CCSprite::create("gameui/rocker_bg.png"); CC_BREAK_IF(pRockerBg==NULL); //pRockerBg->setScale(2.5f); pRockerBg->setPosition(ccp(100,100)); addChild(pRockerBg,enZOrderFront,enTagRockerBg); pRockerBg->setOpacity(100.f); //创建摇杆 CCSprite * pRocker = CCSprite::create("gameui/rocker_ball.png"); CC_BREAK_IF(pRocker==NULL); pRocker->setPosition(pRockerBg->getPosition()); addChild(pRocker,enZOrderFront+1,enTagRocker); pRocker->setOpacity(100.f); //若为副本,则创建按钮 if (m_nStageID >= _NF_TOWN_OR_BATTLE_ID_ && m_nStageID <_NF_TOWN_FB_ID_) { /************************************************************************/ /* 创建按钮 */ /************************************************************************/ //创建菜单 CCMenu * pMenu = CCMenu::create(); CC_BREAK_IF(pMenu==NULL); pMenu->setPosition(CCPointZero); addChild(pMenu,enZOrderFront,enTagMenu); //创建普通攻击按钮 CCSprite * pCommon1 = CCSprite::create("gameui/skill_common.png"); CC_BREAK_IF(pCommon1==NULL); CCSprite * pCommon2 = CCSprite::create("gameui/skill_common.png"); CC_BREAK_IF(pCommon2==NULL); pCommon2->setOpacity(150.f); CCMenuItemSprite * pBtnCommon = CCMenuItemSprite::create(pCommon1,pCommon2,this,menu_selector(CNFRockerLayer::OnBtnCallBack)); CC_BREAK_IF(pBtnCommon==NULL); pBtnCommon->setPosition(ccp(SCREEN_WIDTH - 60,58)); pMenu->addChild(pBtnCommon,enZOrderFront,enTagBtnCommonAttack); CCLabelBMFont* pCommonAttackFont = CCLabelBMFont::create("1","fonts/mhp_num.fnt"); pCommonAttackFont->setPosition(pBtnCommon->getPosition()); this->addChild(pCommonAttackFont,enZOrderFront,enTagCommonAttackFont); CCSprite * pCommon3 = CCSprite::create("gameui/skill_common.png"); CC_BREAK_IF(pCommon3==NULL); pCommon3->setColor(ccRED); pCommon3->setOpacity(100.f); //创建普通攻击CD CCProgressTimer* pProgressCommonAttackCD = CCProgressTimer::create(pCommon3); CC_BREAK_IF(pProgressCommonAttackCD==NULL); pProgressCommonAttackCD->setType(kCCProgressTimerTypeRadial); pProgressCommonAttackCD->setMidpoint(ccp(0.5f,0.5f)); pProgressCommonAttackCD->setPercentage(0.f); pProgressCommonAttackCD->setPosition(pBtnCommon->getPosition()); this->addChild(pProgressCommonAttackCD,enZOrderFront+1,enTagCommonAttackCD); //创建技能按钮 for (int i=enTagBtnSkill1;i<=enTagBtnSkill5;i++) { char szName[NAME_LEN] = {0}; int skilltemp = -1; if(i==enTagBtnSkill1){ skilltemp = m_nSkill_1_ID; }else if(i==enTagBtnSkill2){ skilltemp = m_nSkill_2_ID; }else if(i==enTagBtnSkill3){ skilltemp = m_nSkill_3_ID; }else if(i==enTagBtnSkill4){ skilltemp = m_nSkill_4_ID; }else if(i==enTagBtnSkill5){ skilltemp = m_nSkill_5_ID; } if(skilltemp==-1){ continue; } sprintf(szName,"Skill/r%d_s%d.png",pPro->GetRoleID(),skilltemp); CCSprite * pSpr_n = CCSprite::create(szName); CC_BREAK_IF(pSpr_n==NULL); CCSprite * pSpr_p = CCSprite::create(szName); CC_BREAK_IF(pSpr_p==NULL);; pSpr_p->setColor(ccBLUE); CCSprite * pSpr_d = CCSprite::create(szName); CC_BREAK_IF(pSpr_d==NULL); pSpr_d->setOpacity(150.f); CCSprite * pSpr_CD = CCSprite::create(szName); CC_BREAK_IF(pSpr_CD==NULL); pSpr_CD->setColor(ccRED); //创建技能按钮 CCMenuItemSprite * pBtn = CCMenuItemSprite::create(pSpr_n,pSpr_p,pSpr_d,this,menu_selector(CNFRockerLayer::OnBtnCallBack)); CC_BREAK_IF(pBtn==NULL); pMenu->addChild(pBtn,enZOrderFront,i); if(i==enTagBtnSkill1) pBtn->setPosition(ccp(pBtnCommon->getPositionX()+10,pBtnCommon->getPositionY()+90)); else if(i==enTagBtnSkill2) pBtn->setPosition(ccp(pBtnCommon->getPositionX()-110,pBtnCommon->getPositionY()-5)); else if(i==enTagBtnSkill3) pBtn->setPosition(ccp(pBtnCommon->getPositionX()-70,pBtnCommon->getPositionY()+70)); else if(i==enTagBtnSkill4) pBtn->setPosition(ccp(pBtnCommon->getPositionX()-200,pBtnCommon->getPositionY()-5)); else if(i==enTagBtnSkill5) pBtn->setPosition(ccp(pBtnCommon->getPositionX()+10,pBtnCommon->getPositionY()+170)); //创建技能CD CCProgressTimer* pProgress = CCProgressTimer::create(pSpr_p); CC_BREAK_IF(pProgress==NULL); pProgress->setType(kCCProgressTimerTypeRadial); pProgress->setMidpoint(ccp(0.5f,0.5f)); pProgress->setPercentage(0.f); pProgress->setPosition(pBtn->getPosition()); this->addChild(pProgress,enZOrderFront+1,i+100); //技能CD标签 = 技能标签 + 100 //创建公共CD CCProgressTimer* pProgressCD = CCProgressTimer::create(pSpr_CD); CC_BREAK_IF(pProgressCD==NULL); pProgressCD->setType(kCCProgressTimerTypeRadial); pProgressCD->setMidpoint(ccp(0.5f,0.5f)); pProgressCD->setPercentage(0.f); pProgressCD->setPosition(pBtn->getPosition()); this->addChild(pProgressCD,enZOrderFront+2,i+200); //技能CD标签 = 技能标签 + 200 pProgressCD->setVisible(false); } } //更新函数 schedule(schedule_selector(CNFRockerLayer::update)); return true; } while (false); CCLog("Fun CNFRockerLayer::InitLayer Error!"); return false; }