本文整理汇总了C++中CLabel::setColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CLabel::setColor方法的具体用法?C++ CLabel::setColor怎么用?C++ CLabel::setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLabel
的用法示例。
在下文中一共展示了CLabel::setColor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkMoney
void CSmeltArmor::checkMoney()
{
CCSprite *coin = (CCSprite *)(m_ui->findWidgetById("coin"));
CCSprite *diamond = (CCSprite *)(m_ui->findWidgetById("diamond"));
CLabel *money = (CLabel *)(m_ui->findWidgetById("money"));
if(coin->isVisible())
{
//检查货币数量
if(!CheckCoin(atoi(money->getString())))
{
money->setColor(RGB_RED);
}
else
{
money->setColor(RGB_WHITE);
}
}
if(diamond->isVisible())
{
//检查货币数量
if(!CheckGold(atoi(money->getString())))
{
money->setColor(RGB_RED);
}
else
{
money->setColor(RGB_WHITE);
}
}
}
示例2: createLabel
CLabel* TuiManager::createLabel(float tag, const char* text, const char* font, int alignment, float fontSize, int r, int g, int b, float x, float y, float w, float h,
int r2,int g2,int b2,float strokeSize,int shadowDistance,float shadowBlur,float rotation)
{
CLabel *pLabel = CLabel::createWithTTF(text,font,fontSize);
if(shadowDistance != 0){
pLabel->setTextColor(Color4B(r,g,b,255));
pLabel->enableShadow(Color4B(r2,g2,b2,255),Size(shadowDistance,shadowDistance),shadowBlur);
}
if(strokeSize != 0){
pLabel->setTextColor(Color4B(r,g,b,255));
pLabel->enableOutline(Color4B(r2,g2,b2,255),strokeSize);
}
if(shadowDistance == 0 && strokeSize == 0){
pLabel->setColor(Color3B(r,g,b));
}
pLabel->setAlignment((TextHAlignment)alignment);
pLabel->setDimensions(w,h);
pLabel->setRotation(rotation);
pLabel->setPosition(Point(x+w/2,-(y + h/2)));
pLabel->setTag(tag);
return pLabel;
}
示例3: onCheckAttr
void CSmeltArmor::onCheckAttr(CCObject *pSender, bool bChecked)
{
int checknum =0;
int iShowCount = 0;
for (unsigned int i=0; i<4; ++i)
{
CCheckBox* pCheckBtn = (CCheckBox*)(m_pBaseInfo[i]->findWidgetById("check"));
if (pCheckBtn->isChecked())
{
checknum++;
}
if(m_pBaseInfo[i]->isVisible())
{
iShowCount++;
}
setYellowBgState(pCheckBtn, pCheckBtn->isChecked());
}
//如果选中了四个,则屏蔽掉一个,提示不能全选
if(checknum>=iShowCount && pSender!=nullptr)
{
CCheckBox* pCheck = (CCheckBox*)pSender;
pCheck->setEnabled(false);
pCheck->setChecked(false);
pCheck->setEnabled(true);
setYellowBgState(pCheck, false);
ShowPopTextTip(GETLANGSTR(1182));
return;
}
if (checknum==0)
{
CCSprite *coin = (CCSprite *)(m_ui->findWidgetById("coin"));
coin->setVisible(true);
m_coin = 0;
switch (m_armor.quality)
{
case 1:
m_coin =10000;
break;
case 2:
m_coin =20000;
break;
case 3:
m_coin =40000;
break;
case 4:
m_coin =80000;
break;
case 5:
m_coin =160000;
break;
default:
break;
}
m_diamond = 0;
CCSprite *diamond = (CCSprite *)(m_ui->findWidgetById("diamond"));
diamond->setVisible(false);
CLabel *money = (CLabel *)(m_ui->findWidgetById("money"));
money->setString(ToString(m_coin));
//检查货币数量
if(!CheckCoin(atoi(money->getString())))
{
money->setColor(RGB_RED);
}
else
{
money->setColor(RGB_WHITE);
}
showFireWithType(0);
}
else
{
CCSprite *coin = (CCSprite *)(m_ui->findWidgetById("coin"));
coin->setVisible(false);
CCSprite *diamond = (CCSprite *)(m_ui->findWidgetById("diamond"));
diamond->setVisible(true);
CLabel *money = (CLabel *)(m_ui->findWidgetById("money"));
money->setString(ToString(100*checknum));
//检查货币数量
if(!CheckGold(atoi(money->getString())))
{
money->setColor(RGB_RED);
}
else
{
money->setColor(RGB_WHITE);
}
m_coin = 0;
m_diamond = 100*checknum;
showFireWithType(1);
//.........这里部分代码省略.........
示例4: onEnter
void CMainCityUI::onEnter()
{
BaseLayer::onEnter();
UserData *user = DataCenter::sharedData()->getUser()->getUserData();
//角色信息相对位置处理
CLayout* headPart = (CLayout*)m_ui->findWidgetById("head_part");
headPart->setPosition(m_ui->convertToNodeSpace(ccp(VLEFT+headPart->getContentSize().width/2, VTOP-headPart->getContentSize().height/2)));
//显示角色名,等级,体力,金币
CLabel *nameLabel = (CLabel*)headPart->getChildByTag(10);
nameLabel->setString(user->getRoleName().c_str());
nameLabel->setColor(RGB_ROLE_COLOR);
CLabel *level = (CLabel*)(headPart->findWidgetById("level"));
level->setString(CCString::createWithFormat("Lv%d",user->getLevel())->getCString());
CProgressBar *progressBar = (CProgressBar*)(headPart->getChildByTag(11));
progressBar->setMaxValue(user->getNextExp());
progressBar->startProgress(user->getExp(),0.3f);
CLabelAtlas *vip_level = (CLabelAtlas*)(headPart->findWidgetById("level_vip"));
vip_level->setString(ToString(user->getVip()));
if (user->getVip()==0)
{
vip_level->setVisible(false);
CLabelAtlas *vip_font = (CLabelAtlas*)(headPart->findWidgetById("vip_font"));
vip_font->setVisible(false);
}
CImageView *headbg = (CImageView *)(headPart->findWidgetById("headbg"));
headbg->setTouchEnabled(true);
headbg->setOnClickListener(this, ccw_click_selector(CMainCityUI::onHeadImgBtn));
CButton *button = nullptr;
int i = 1;
for (; i<=9; ++i)
{
CCNode *lay = dynamic_cast<CCNode*>( m_ui->getChildByTag(i));
button = dynamic_cast<CButton*>(lay->getChildByTag(i));
// button->setEnabled(false);
button->setOnClickListener(this, ccw_click_selector(CMainCityUI::onClickBtn));
button->setSelectedTexture(((CCSprite*)(button->getNormalImage()))->getTexture());
button->getSelectedImage()->setScale(1.1f);
m_btnPos[i] = button->getPosition();
}
CCSprite* head = (CCSprite*)headPart->getChildByTag(15);
if (user->getThumb()>0)
{
CCTexture2D *texture = CCTextureCache::sharedTextureCache()
->addImage(CCString::createWithFormat("headIcon/%d.png", user->getThumb())->getCString());
if (texture)
{
head->setTexture(texture);
}
}
else
{
string fbName = user->getFbId()+".jpg";
string fullName = CCFileUtils::sharedFileUtils()->fullPathForFilename(fbName.c_str());
bool isFileExist = CCFileUtils::sharedFileUtils()->isFileExist(fullName);
if(isFileExist)
{
CCSprite *headBg = (CCSprite *)(headPart->findWidgetById("headbg"));
CCSprite *sp = CCSprite::create(fbName.c_str());
CCSprite* spr = MakeFaceBookHeadToCircle(sp);
spr->setPosition(headBg->getPosition());
headPart->removeChild(head);
spr->setTag(15);
headPart->addChild(spr);
}
else
{
HttpLoadImage::getInstance()->bindUiTarget(this);
CCString *imgUrl = CCString::createWithFormat(FACEBOOKIMG_106,user->getFbId().c_str());
HttpLoadImage::getInstance()->requestUrlImage(imgUrl->getCString(),user->getFbId().c_str());
}
}
CImageView* vip = (CImageView*)headPart->findWidgetById("vip");
vip->setTouchEnabled(true);
vip->setOnClickListener(this,ccw_click_selector(CMainCityUI::onVip));
//添加签到,充值等其他入口
CAccessLayer* pAccess = CAccessLayer::create();
this->addChild(pAccess, 99);
CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_HERO,this,GameMsghandler_selector(CMainCityUI::updateRoleProperty));
CSceneManager::sharedSceneManager()->addMsgObserver(TASK_NOTICE,this,GameMsghandler_selector(CMainCityUI::updateTaskNotice));
CSceneManager::sharedSceneManager()->addMsgObserver(MAIL_NOTICE,this,GameMsghandler_selector(CMainCityUI::updateMailNotice));
CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_FUNCTIONOPEN,this,GameMsghandler_selector(CMainCityUI::updateFuctionOpen));
CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_GAMETIP,this,GameMsghandler_selector(CMainCityUI::updateGameTip));
CSceneManager::sharedSceneManager()->addMsgObserver(SHOW_HEAD,this,GameMsghandler_selector(CMainCityUI::showHead));
CCSprite *red = (CCSprite*)(m_ui->findWidgetById("redPoint"));
CCSprite *mailPoint = (CCSprite*)(m_ui->findWidgetById("mailPoint"));
//.........这里部分代码省略.........