本文整理汇总了C++中CButton::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ CButton::addChild方法的具体用法?C++ CButton::addChild怎么用?C++ CButton::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CButton
的用法示例。
在下文中一共展示了CButton::addChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSelectCity
void CCommandLayer::onSelectCity(CCObject* pSender)
{
CButton *btn = (CButton*)pSender;
// m_selectCellImg->setPosition(btn->getParent()->convertToWorldSpace(btn->getPosition()));
m_selectCellImg->removeFromParent();
btn->addChild(m_selectCellImg);
m_selectCellImg->setVisible(true);
m_selectCellImg->setPosition(ccp(btn->getContentSize().width/2,btn->getContentSize().height/2));
m_selectCity = (CCity*)btn->getUserData();
updateSelectCity(m_selectCity);
}
示例2: updateHero
void CCommandLayer::updateHero(const TMessage& tMsg)
{
//清空
if (tMsg.nMsg ==0)
{
CButton *btn = (CButton*)(m_garrsionLayer->getChildByTag(m_selectHero));
btn->removeChildByTag(1);
CHero hero;
hero.id= 0;
// memset((void*)&hero,0,sizeof(CHero));
m_city.heroList[m_selectHero-1] = hero;
//
CCNode *lab = (CCNode*)m_garrsionLayer->findWidgetById(CCString::createWithFormat("lab%d",m_selectHero)->getCString());
lab->setVisible(true);
}
else
{
CButton *btn = (CButton*)(m_garrsionLayer->getChildByTag(m_selectHero));
CHero *hero = (CHero*)tMsg.lParam;
string icon = ToString(hero->thumb);
btn->removeChildByTag(1);
CCNode *lab = (CCNode*)m_garrsionLayer->findWidgetById(CCString::createWithFormat("lab%d",m_selectHero)->getCString());
lab->setVisible(false);
CCSprite *head = CCSprite::create(CCString::createWithFormat("headImg/%d.png",hero->thumb)->getCString());
if (!head)
{
head = CCSprite::create("headImg/101.png");
CCLOG("[ ERROR ] CCommandLayer::updateHero Lost Image = %d",hero->thumb);
}
head->setPosition(ccp(btn->getContentSize().width/2, btn->getContentSize().height/2));
head->setTag(1);
head->setScale(82.0f/100.0f);
btn->addChild(head);
btn->setEnabled(false);
head->setColor(RGB_GRAY_COLOR);
if (m_selectHero>m_city.heroList.size())
{
m_city.heroList.push_back(*hero);
}
else
{
m_city.heroList[m_selectHero-1] = *hero;
}
delete hero;
}
}
示例3: showBuildInfo
void CCommandLayer::showBuildInfo(const CCity& ct)
{
int i=0;
for (; i<ct.heroList.size()&&i<3; i++)
{
CButton *btn = (CButton*)(m_garrsionLayer->getChildByTag(i+1));
const CHero &hero = ct.heroList[i];
if (hero.thumb!=0)
{
CCSprite *head = CCSprite::create(CCString::createWithFormat("headImg/%d.png",hero.thumb)->getCString());
if (!head)
{
head = CCSprite::create("headImg/101.png");
CCLOG("[ ERROR ] CCommandLayer::showBuildInfo Lost Image = %d",hero.thumb);
}
head->setPosition(ccp(btn->getContentSize().width/2, btn->getContentSize().height/2));
head->setTag(1);
head->setScale(82.0f/100.0f);
btn->addChild(head);
if (!hero.remove)
{
btn->setEnabled(false);
head->setColor(RGB_GRAY_COLOR);
}
}
CCNode *lab = (CCNode*)m_garrsionLayer->findWidgetById(CCString::createWithFormat("lab%d",i+1)->getCString());
lab->setVisible(false);
}
for (i=ct.heroNum;i<3;i++)
{
CButton *btn = (CButton*)(m_garrsionLayer->getChildByTag(i+1));
btn->setEnabled(false);
CCNode *lab = (CCNode*)m_garrsionLayer->findWidgetById(CCString::createWithFormat("lab%d",i+1)->getCString());
lab->setVisible(false);
}
//runFadeAction(ct);
}
示例4: updateStar
void CSmeltArmor::updateStar( const TMessage& tMsg )
{
//加号
CItem* pData = (CItem*)tMsg.lParam;
if(pData)
{
//自己的数据不更新
if(&(m_armor) == pData)
{
return;
}
CCSprite *why = dynamic_cast<CCSprite*>(m_ui->findWidgetById("why"));
if(why->isVisible())
{
return;
}
CButton *btn = dynamic_cast<CButton*>(m_ui->findWidgetById("select"));
btn->removeChildByTag(415);
CLayout* pStarLayout = getStarLayout(pData->iStar);
btn->addChild(pStarLayout, 415, 415);
}
}
示例5: showSmeltDataToUI
void CSmeltArmor::showSmeltDataToUI()
{
const ItemData * itemData = DataCenter::sharedData()->getItemDesc()->getCfg(m_armor.itemId);
//贴图
CCSprite *prop = getItemSprite(&m_armor);
if (!prop)
{
prop = CImageView::create("prop/32003.png");
}
//选择按钮
CButton *btn = dynamic_cast<CButton*>(m_ui->findWidgetById("select"));
btn->removeChildByTag(1);
prop->setPosition(ccp(btn->getContentSize().width/2,btn->getContentSize().height/2));
prop->setTag(1);
btn->addChild(prop, -1);
((CCSprite*)btn->getNormalImage())->setTexture(setItemQualityTexture(m_armor.quality));
//添加星星层
btn->removeChildByTag(415);
CLayout* pStarLayout = getStarLayout(m_armor.iStar);
btn->addChild(pStarLayout, 415, 415);
//更新名字
CLabel *name = dynamic_cast<CLabel*>(m_ui->findWidgetById("name"));
CCString *str = CCString::create("XXX");
if(itemData)
{
str = CCString::createWithFormat("%s",itemData->itemName.c_str());
}
name->setString(str->getCString());
name->setVisible(true);
//加号
CCSprite *why = dynamic_cast<CCSprite*>(m_ui->findWidgetById("why"));
why->setVisible(false);
//设置等级
CLabel* pLevel = dynamic_cast<CLabel*>(m_ui->findWidgetById("level"));
CCNode* pLevelBg = dynamic_cast<CCNode*>(m_ui->findWidgetById("level_mask"));
if(m_armor.itemLevel>0)
{
pLevel->setVisible(true);
pLevelBg->setVisible(true);
pLevel->setString(CCString::createWithFormat("+%d", m_armor.itemLevel)->getCString());
}
else
{
pLevel->setVisible(false);
pLevelBg->setVisible(false);
}
m_attr->setVisible(true);
//显示背景框等等
CCNode* pNode4 = (CCNode*)m_ui->findWidgetById("tip");
pNode4->setVisible(false);
m_pSpineHero->setVisible(false);
initSpandAndCheckBox();
showArmorAttr();
//更新钱
onCheckAttr(nullptr, false);
//设置动作
showMoveAction("box_bg");
showMoveAction("select");
showMoveAction("why");
showMoveAction("level");
showMoveAction("level_mask");
}