本文整理汇总了C++中CCMenuItemSprite::setEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemSprite::setEnabled方法的具体用法?C++ CCMenuItemSprite::setEnabled怎么用?C++ CCMenuItemSprite::setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemSprite
的用法示例。
在下文中一共展示了CCMenuItemSprite::setEnabled方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tabMenuHandler
void HelpScene::tabMenuHandler(CCObject* pSender){
CCMenuItemSprite* sprMenu = (CCMenuItemSprite*)pSender;
int zOrder = sprMenu->getZOrder();
helpLayers->switchTo(zOrder);
helpBtn->setEnabled(true);
monsterBtn->setEnabled(true);
towerBtn->setEnabled(true);
sprMenu->setEnabled(false);
}
示例2: updateMe
void LayerGoods::updateMe()
{
UserInfo *user_info = Topwo::getInstance()->getTopwoData()->getUserInfo();
CCMenu* menu = static_cast<CCMenu*>(this->getChildByTag(0));
//体魄
int goods_level = 0;
CCMenuItemSprite* item = NULL;
CCSprite* sprite = NULL;
CCLabelAtlas* la = NULL;
for (int i = 1; i <= 5; i++)
{
if (i == 1)
{
goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelTiPo());
}
else if (i == 2)
{
goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelMeiLi());
}
else if (i == 3)
{
goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelZhiLi());
}
else if (i == 4)
{
goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelEQ());
}
else if (i == 5)
{
goods_level = getGoodsLevel(user_info->getCurrentGoodsLevelGanXing());
}
item = static_cast<CCMenuItemSprite*>(menu->getChildByTag(i));
if (goods_level >= 9)
{
item->setEnabled(false);
item->setColor(ccc3(128, 128, 128));
}
sprite = static_cast<CCSprite*>(this->getChildByTag(i));
la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(0));
la->setString(CCString::createWithFormat("%d", goods_level)->getCString());
la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(1));
la->setString(CCString::createWithFormat("%d", getGoodsBonus(goods_level))->getCString());
la = static_cast<CCLabelAtlas*>(sprite->getChildByTag(2));
la->setString(CCString::createWithFormat("%d", getGoodsPrice(goods_level))->getCString());
}
SceneMain* scene_main = static_cast<SceneMain*>(CCDirector::sharedDirector()->getRunningScene()->getChildByTag(0));
scene_main->updateMe();
}
示例3: heroUp
void PrepareLayer::heroUp(CCObject *pSender)
{
int upCount = CCUserDefault::sharedUserDefault()->getIntegerForKey("heropUp",0);
CCUserDefault::sharedUserDefault()->setIntegerForKey("heropUp",upCount+1);
if(upCount %3==0)
{
showFullUpgrade();
}
else
{
int curLevel = GameConfigData::initialGameData().getCurHeroLevel();
HeroUpgradeData upHeroData = DataInitial::initialDataSource().getHeroUpgrateData(m_curShowHeroId,curLevel);
int nexPriece = upHeroData.mlevelPrice;
if (nexPriece <= GameConfigData::initialGameData().getCoinValue())
{
int coinValue = GameConfigData::initialGameData().getCoinValue() - nexPriece;
GameConfigData::initialGameData().setCoinValue(coinValue);
curLevel++;
GameConfigData::initialGameData().setCurHeroLevel(curLevel);
playUpEffect(curLevel);
if (curLevel >= HERO_MAXLEVEL)
{
CCMenuItemSprite *upItem = (CCMenuItemSprite*)pSender;
upItem->setEnabled(false);
upItem->setVisible(false);
if (this->getChildByTag(1430))
{
this->getChildByTag(1430)->setVisible(false);
}
}
}
else
{
/*
JniCall::sharedJniCall()->setBuyFailedCallBack(this,callFunStr_selector(PrepareLayer::purchaseFailed));
JniCall::sharedJniCall()->setBuyCompleteCallBack(this,callFunStr_selector(PrepareLayer::purchaseSuccess));
JniCall::sharedJniCall()->purchaseByIndex(8);*/
showFullUpgrade(1);
}
}
}
示例4: adjustMap
void LevelMap::adjustMap(bool isResetLevel)
{
int num = floor(offsetY/442);
currentMap = -num;
int offnum = num%3;
float tmpoff = offsetY - num*442;
mapLayer->setPosition(ccp(0, (offnum-1)*442 + tmpoff));
if(isResetLevel)
{
int offlevel = 1000 + currentMap*3 -3;
for (int i = 0; i < 9 ; i++)
{
MapItem* tmpLevelItemData = NULL;
tmpLevelItemData = CData::getCData()->getConfigOfMapLevel(offlevel + i);
CCMenuItemSprite* tmp = (CCMenuItemSprite*)levelSpDic->objectForKey(i);
tmp->removeChildByTag(9999);
if (tmpLevelItemData!= NULL && tmpLevelItemData->bid < currentLevelId)
{
CCSize tmpsz = tmp->getContentSize();
CCSprite* ssp = CCSprite::create();
int num = data["citylist"][tmpLevelItemData->bid - 1000].asInt();
for (int k = 0; k<num; k++)
{
CCSprite * star = CCSprite::create("zjm_star.png");
star->setPosition(ccp(k*30, 0));
ssp->addChild(star);
}
ssp->setPosition(ccp(tmpsz.width/2-15*num+15, 0));
ssp->setTag(9999);
tmp->addChild(ssp, 0);
}
if(tmpLevelItemData != NULL)
{
if(tmpLevelItemData->bid > currentLevelId)
{
tmp->setEnabled(false);
}
else
{
tmp->setEnabled(true);
}
tmp->setUserObject(tmpLevelItemData);
}
//for (int j = 1001; j<=1005; j++)
//{
CCLabelTTF* tmpName = (CCLabelTTF*)(tmp->getChildByTag(1002));
if(tmpLevelItemData)
{
tmpName->setString(tmpLevelItemData->nickname.c_str());
}
//}
}
}
levelsMenu->setPosition(ccp(0, -442 + tmpoff));
}
示例5: update
//.........这里部分代码省略.........
}
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));
示例6: init
//.........这里部分代码省略.........
{
CCSprite *spNml = CCSprite::create(fName[i]);
CCSprite *spSel = CCSprite::create(fName[i]);
spSel->setColor(ccc3(80,80,80));
CCMenuItemSprite *itemSp = CCMenuItemSprite::create(spNml,spSel,
this,menu_selector(PrepareLayer::menuTouch));
if(i==2)
{
m_menu->addChild(itemSp,1,100+i);
itemSp->setPosition(posArray[i]);
itemSp->setScale(0.8f);
}
else if(i ==3)
{
m_menu->addChild(itemSp,1,100+i);
itemSp->setPosition(posArray[i]);
itemSp->setScale(PRE_SCALE);
CCLabelBMFont *upGrade = CCLabelBMFont::create(gGetLanguageDesc(K.UPGRADE_DES).c_str(),"font/upgrade_des.fnt");
itemSp->addChild(upGrade);
upGrade->setPosition(ccp(80*gScaleX,-25*gScaleY));
}
else
{
m_menu->addChild(itemSp,1,100+i);
itemSp->setPosition(posArray[i]);
}
}
int curLevel = GameConfigData::initialGameData().getCurHeroLevel();
if (curLevel >= HERO_MAXLEVEL)
{
CCMenuItemSprite *upItem = (CCMenuItemSprite*)m_menu->getChildByTag(103);
upItem->setEnabled(false);
upItem->setVisible(false);
if (this->getChildByTag(1430))
{
this->getChildByTag(1430)->setVisible(false);
}
}
//金币放置最上方商城
CCSprite *coinIcon = CCSprite::create("ui/shared/coin.png");
this->addChild(coinIcon,2,1429);
coinIcon->setPosition(ccp(280 * gScaleX, size.height - 30 * gScaleY));
m_moneyLabel = CCLabelBMFont::create("10000000","font/level_big.fnt");
this->addChild(m_moneyLabel,4);
m_moneyLabel->setAnchorPoint(ccp(0,0.5f));
m_moneyLabel->setPosition(ccp(300*gScaleX,size.height-25*gScaleY));
m_moneyLabel->setScale(0.6F);
setCoin();
//升级所需金币数
m_nextLevelPriceLabel = CCLabelBMFont::create("1000000000","font/level_big.fnt");
this->addChild(m_nextLevelPriceLabel,2);
m_nextLevelPriceLabel->setPosition(ccp(345*gScaleX,342*gScaleY));
m_nextLevelPriceLabel->setScale(0.45);
int curHeroId = GameConfigData::initialGameData().getCurHeroId();
int heroLevel = GameConfigData::initialGameData().getCurHeroLevel();
//名字label
m_heroNameLabel = CCLabelBMFont::create("name","font/hero_name.fnt");