本文整理汇总了C++中CLabel::setString方法的典型用法代码示例。如果您正苦于以下问题:C++ CLabel::setString方法的具体用法?C++ CLabel::setString怎么用?C++ CLabel::setString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLabel
的用法示例。
在下文中一共展示了CLabel::setString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showItem
void CHeroExpItem::showItem(CItem* item)
{
const ItemData * itemData = DataCenter::sharedData()->getItemDesc()->getCfg(item->itemId);
CImageView *itembg1 = (CImageView *)(m_ui->findWidgetById("itembg1"));
CImageView *mask1 = (CImageView *)(m_ui->findWidgetById("mask1"));
mask1->setTexture(setItemQualityTexture(item->quality));
CCSprite *head = getItemSprite(item);
if (!head)
{
head = CCSprite::create("prop/32003.png");
CCLOG("[ ERROR ] CHeroExpItem::showItem Lost Image = %d",item->iconId);
}
if (head)
{
head->setScale(82.0f/100.0f);
head->setPosition(ccp(itembg1->getContentSize().width/2, itembg1->getContentSize().height/2));
itembg1->addChild(head);
}
CLabel *name = (CLabel *)(m_ui->findWidgetById("name"));
if(itemData)
{
name->setString(itemData->itemName.c_str());
}
CLabel *num = (CLabel *)(m_ui->findWidgetById("num"));
num->setString(ToString(item->itemNum));
}
示例2: addTableCell
void CHeroExpItem::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
CLayout *lay = UICloneMgr::cloneLayout(m_cell);
const CEvolQuest &evol = m_evolInfo.questsList.at(uIdx);
const TaskData *task = DataCenter::sharedData()->getTask(Evole_Task)->getCfg(evol.id);
for (int i = 1; i <=4; i++)
{
CCNode *child = lay->getChildByTag(i);
lay->removeChild(child);
pCell->addChild(child);
if (i==1)
{
CImageView *bgView= (CImageView*)child;
bgView->setTouchEnabled(true);
bgView->setUserData(&m_evolInfo.questsList.at(uIdx));
bgView->setOnClickListener(this, ccw_click_selector(CHeroExpItem::onRecvTask));
}
else if (i==2)
{
CLabel *taskName = (CLabel*)child;
taskName->setString(task->taskName.c_str());
}
else if (i==3)
{
CLabel *taskDesc = (CLabel*)child;
taskDesc->setString(task->taskDesc.c_str());
}
else if (i==4)
{
child->setVisible(evol.pass);
}
}
}
示例3: updateData
void CHeroEvolveEffectLayer::updateData( )
{
//面板数据
int iValue[][2] = {
{m_pBaseHero->combat, m_pAimHero->combat},
{m_pBaseHero->hp, m_pAimHero->hp},
{m_pBaseHero->atk, m_pAimHero->atk},
{m_pBaseHero->def, m_pAimHero->def},
{m_pBaseHero->dex, m_pAimHero->dex},
{m_pBaseHero->hit, m_pAimHero->hit},
{m_pBaseHero->crit, m_pAimHero->crit},
{m_pBaseHero->dodge, m_pAimHero->dodge},
{m_pBaseHero->renew, m_pAimHero->renew}
};
//更新数据
for(int i=0; i<9; i++)
{
CLayout *pLay = (CLayout *)m_pUI->findWidgetById(CCString::createWithFormat("data%d", i+1)->getCString());
pLay->setVisible(false);
CLabel *pBaseValue = (CLabel *)pLay->findWidgetById(CCString::createWithFormat("base_value%d", i+1)->getCString());
pBaseValue->setString(ToString(iValue[i][0]));
CLabel *pAimValue = (CLabel *)pLay->findWidgetById(CCString::createWithFormat("aim_value%d", i+1)->getCString());
pAimValue->setString(ToString(iValue[i][1]));
}
}
示例4: updateSelectCity
void CCommandLayer::updateSelectCity(CCity *data)
{
CCSprite *build = (CCSprite*)(m_comLayer->findWidgetById("build"));
CCTexture2D *textTure = CCTextureCache::sharedTextureCache()->addImage(CCString::createWithFormat("command/%d.jpg",data->cityId*10+1)->getCString());
if (textTure)
{
build->setTexture(textTure);
}
CLabel *food = (CLabel*)(m_comLayer->findWidgetById("food"));
food->setString(ToString(data->lvFood));
CLabel *heronum = (CLabel*)(m_comLayer->findWidgetById("heronum"));
heronum->setString(CCString::createWithFormat("%d/%d",data->haveHeroNum,data->heroNum)->getCString());
CLabel *note1 = (CLabel*)(m_comLayer->findWidgetById("func1"));
CLabel *note2 = (CLabel*)(m_comLayer->findWidgetById("func2"));
CCArray *strArr = strSplit(data->note.c_str(),"|");
if (strArr->count()==1)
{
note1->setString(((CCString*)strArr->objectAtIndex(0))->getCString());
note2->setString("");
}
else if (strArr->count()==2)
{
note1->setString(((CCString*)strArr->objectAtIndex(0))->getCString());
note2->setString(((CCString*)strArr->objectAtIndex(1))->getCString());
}
CButton *command = (CButton*)(m_comLayer->findWidgetById("strengthen"));
UserData *user = DataCenter::sharedData()->getUser()->getUserData();
if (data->cityId != m_commandData.cityInfo.cityId)
{
if (user->getRoleFood()>=data->lvFood&&data->level< m_commandData.cityInfo.level)
{
command->setEnabled(true);
}
else
{
command->setEnabled(false);
}
}
else
{
if (user->getRoleFood()>=data->lvFood)
{
command->setEnabled(true);
}
else
{
command->setEnabled(false);
}
}
}
示例5: updateSelectServer
void LoginLayerUC::updateSelectServer()
{
const Server& gameServer = m_serverInfo.server_list().Get(m_iSelectServerIndex);
CLabel* pServerSelect = (CLabel*)m_pCurrentServerUI->findWidgetById("server_select");
pServerSelect->setString(gameServer.server_name().c_str());
CLabel* pServerSelectStatus = (CLabel*)m_pCurrentServerUI->findWidgetById("status_select");
int iShowText[5] = {2002, 1184, 1185, 1186, 1187};
pServerSelectStatus->setString(GETLANGSTR(iShowText[gameServer.server_status()]));
UCSdk::s_serverid = 0;
UCSdk::s_servername = gameServer.server_name();
}
示例6: onCheck
void CToggleViewGroupTest::onCheck(Ref* pSender, bool bChecked)
{
CToggleView* pToggle = (CToggleView*) pSender;
CLabel* pText = (CLabel*) pToggle->getUserObject();
if( bChecked )
{
pText->setString("checked");
}
else
{
pText->setString("unchecked");
}
}
示例7: updateInfoToUIAndReturnCount
int CSmeltArmor::updateInfoToUIAndReturnCount( CLayout* pLayout[], int iNameId[], int iValue[], const char* sRange[], int iMax, const char* sTitle )
{
int iMaxLineCount = 0;
for(unsigned int i=0; i<iMax; i++)
{
//有值
if(iValue[i] > 0)
{
pLayout[iMaxLineCount]->setVisible(true);
//设置名称
CLabel* pInfoType = (CLabel*)pLayout[iMaxLineCount]->findWidgetById("info_type");
pInfoType->setString(GETLANGSTR(iNameId[i]));
//设置值大小
CLabel* pValue = (CLabel*)pLayout[iMaxLineCount]->findWidgetById("value");
if(atoi(pValue->getString())!=iValue[i])
{
pValue->setString(ToString(iValue[i]));
pValue->runAction(CCRollLabelAction::create(0.3f, 0, iValue[i], pValue));
}
//目标值大小
CLabel* pAimValue = (CLabel*)pLayout[iMaxLineCount]->findWidgetById("aim_value");
pAimValue->setString(sRange[i]);
//存ID
CCheckBox* pCheck = (CCheckBox*)pLayout[iMaxLineCount]->findWidgetById("check");
pCheck->setTag(i+1);
iMaxLineCount++;
}
//找到四个了,退出循环
if(iMaxLineCount>=4)
{
break;
}
}
//隐藏掉没有数据填充的cell
hideNoneValueCell(iMaxLineCount, pLayout);
//如果一个都没有,隐藏标题
if(sTitle != nullptr)
{
CCNode* pNode = (CCNode*)m_ui->findWidgetById(sTitle);
if(pNode)
{
pNode->setVisible(iMaxLineCount != 0);
}
}
return iMaxLineCount;
}
示例8: updateSignDays
void CSignLayer::updateSignDays()
{
//更新已签天数
CLabel * pSignNum = (CLabel*)m_ui->findWidgetById("qiandao_num");
pSignNum->setString(ToString(m_signData.sign));
if(!m_signData.bCanSign)
{
//更新已签天数
CButton * pSignBtn = (CButton*)m_ui->findWidgetById("qiandao_btn");
pSignBtn->setEnabled(false);
pSignBtn->getDisabledImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
}
//未补签天数
CLabel* pRemainResignNum = (CLabel*)m_ui->findWidgetById("buqian_num");
pRemainResignNum->setString(ToString(m_signData.resign));
if(!m_signData.bCanResign || m_signData.resign==0)
{
//更新已签天数
//CButton * pReSignBtn = (CButton*)m_ui->findWidgetById("buqian_btn");
//pReSignBtn->setEnabled(false);
//pReSignBtn->getDisabledImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
pRemainResignNum->setVisible(false);
CLabel* pRemainResignText = (CLabel*)m_ui->findWidgetById("buqian_text");
pRemainResignText->setVisible(false);
CLabel* pRemainResignBg = (CLabel*)m_ui->findWidgetById("buqian_bg");
pRemainResignBg->setVisible(false);
CLabel* pRemainResignBtn = (CLabel*)m_ui->findWidgetById("buqian_btn");
pRemainResignBtn->setVisible(false);
CLabel* pRemainResignBtnText = (CLabel*)m_ui->findWidgetById("buqian_btn_text");
pRemainResignBtnText->setVisible(false);
}
////totalSign
//for (int i = 0; i < m_signData.totalList.size()&&i<4; i++)
//{
// CSign &sign = m_signData.totalList.at(i);
// if (m_signData.sign >= sign.day)
// {
// CCSprite *getspr = (CCSprite*)(m_ui->findWidgetById(CCString::createWithFormat("get%d",i+1)->getCString()));
// getspr->setVisible(true);
// }
//}
}
示例9: addTableCell
void LoginLayerUC::addTableCell( unsigned int uIdx, CTableViewCell * pCell )
{
CLayout *lay = UICloneMgr::cloneLayout(m_pCell);
const Server& server = m_serverInfo.server_list().Get(uIdx);
for (unsigned int i=1; i<=4; i++)
{
CCNode *child = lay->getChildByTag(i);
lay->removeChild(child);
child->setTag(i);
pCell->addChild(child);
pCell->setTag(uIdx);
switch (i)
{
case 1:
{
CImageView* pBoard = (CImageView*)child;
pBoard->setTouchEnabled(true);
pBoard->setOnClickListener(this, ccw_click_selector(LoginLayerUC::selectServer));
}
break;
case 3:
{
CLabel* pLabel = (CLabel*)child;
pLabel->setString(server.server_name().c_str());
}
break;
case 4:
{
CLabel* pLabel = (CLabel*)child;
int iShowText[5] = {2002, 1184, 1185, 1186, 1187};
pLabel->setString(GETLANGSTR(iShowText[server.server_status()]));
}
break;
default:
break;
}
}
}
示例10: updateUI
void CHandBookHeroLayer::updateUI( )
{
//图鉴收集比例
int iCurrentN = CompleteInHandBook(&m_AtlasResponse);
int iMax = m_AtlasResponse.atlas_list_size();
CLabel *pText = (CLabel *)m_ui->findWidgetById("text");
pText->setString(CCString::createWithFormat("%d/%d", iCurrentN, iMax)->getCString());
m_pTableView->setCountOfCell(m_AtlasResponse.atlas_list_size());
m_pTableView->reloadData();
}
示例11: onEnter
void CTopLayer::onEnter()
{
BaseLayer::onEnter();
this->setTouchPriority(-100);
UserData *user = DataCenter::sharedData()->getUser()->getUserData();
m_coinLabel = (CLabel*)m_ui->getChildByTag(13);
m_coinLabel->setString(ToString(user->getCoin()));
m_moneyLabel = (CLabel*)m_ui->getChildByTag(14);
m_moneyLabel->setString(ToString(user->getRoleGold()));
//
m_foodLabel = (CLabel*)m_ui->getChildByTag(17);
//m_foodLabel->setString(ToString(user->getRoleFood()));
m_foodLabel->setString(ToString(user->getFriends()));
CLabel *action = (CLabel*)(m_ui->findWidgetById("action"));
action->setString(CCString::createWithFormat("%d/%d",user->getRoleAction(),user->getActionLimit())->getCString());
CButton* add_food = (CButton*)m_ui->findWidgetById("btn_add_food");
CButton* add_copper = (CButton*)m_ui->findWidgetById("btn_add_copper");
CButton* add_soul = (CButton*)m_ui->findWidgetById("btn_add_soul");
CButton* add_gold = (CButton*)m_ui->findWidgetById("btn_add_gold");
CButton* add_friendship = (CButton*)m_ui->findWidgetById("btn_add_friendship");
add_food->getSelectedImage()->setScale(1.1f);
add_copper->getSelectedImage()->setScale(1.1f);
add_soul->getSelectedImage()->setScale(1.1f);
add_gold->getSelectedImage()->setScale(1.1f);
add_friendship->getSelectedImage()->setScale(1.1f);
add_food->setOnClickListener(this, ccw_click_selector(CTopLayer::onAddResourceBtn));
add_copper->setOnClickListener(this, ccw_click_selector(CTopLayer::onAddResourceBtn));
add_soul->setOnClickListener(this, ccw_click_selector(CTopLayer::onAddResourceBtn));
add_gold->setOnClickListener(this, ccw_click_selector(CTopLayer::onAddResourceBtn));
add_friendship->setOnClickListener(this, ccw_click_selector(CTopLayer::onAddResourceBtn));
CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_HERO,this,GameMsghandler_selector(CTopLayer::updateRoleProperty));
//绑定场景隐藏和显示的消息
NOTIFICATION->addObserver(this, callfuncO_selector(CTopLayer::show), SHOW_TOP_LAYER, nullptr);
NOTIFICATION->addObserver(this, callfuncO_selector(CTopLayer::hide), HIDE_TOP_LAYER, nullptr);
CImageView *coin = (CImageView*)(m_ui->findWidgetById("coin"));
CCAnimation *coinAnim = AnimationManager::sharedAction()->getAnimation("7033");
coinAnim->setDelayPerUnit(0.3f);
coin->runAction(CCRepeatForever::create(CCAnimate::create(coinAnim)));
CImageView *gold = (CImageView*)(m_ui->findWidgetById("gold"));
CCAnimation *goldAnim = AnimationManager::sharedAction()->getAnimation("7034");
goldAnim->setDelayPerUnit(0.3f);
gold->runAction(CCRepeatForever::create(CCAnimate::create(goldAnim)));
}
示例12: updateActionTime
void CTopLayer::updateActionTime(float dt)
{
UserData *data = DataCenter::sharedData()->getUser()->getUserData();
if (data->getRoleAction() < data->getActionLimit())
{
data->setRoleAction(data->getRoleAction()+1);
CLabel *action = (CLabel*)(m_ui->findWidgetById("action"));
action->setString(CCString::createWithFormat("%d/%d",data->getRoleAction(),data->getActionLimit())->getCString());
data->setActionTime(data->getActionTime() + data->getInterval()*60*60);
}
else
{
this->unschedule(schedule_selector(CTopLayer::updateActionTime));
}
}
示例13: updateTotoalSign
void CSignLayer::updateTotoalSign()
{
//更新
//已领取的,宝箱变灰,加对勾
//未领取的,宝箱变亮,
//将要领取的,加黄色标题突出
for (int i = 0; i < m_signData.totalList.size()&&i<4; i++)
{
CSign &sign = m_signData.totalList.at(i);
//宝箱
CImageView *mask = (CImageView*)m_ui->findWidgetById(CCString::createWithFormat("mask%d",i+1)->getCString());
mask->setVisible(true);
//mask->setTexture(CCTextureCache::sharedTextureCache()->addImage(CCString::createWithFormat("sign/box_%d.png", i+1)->getCString()));
mask->setUserData(&sign);
mask->setTouchEnabled(true);
mask->setOnPressListener(this, ccw_press_selector(CSignLayer::onPress));
//天数
CLabel *day = (CLabel*)(m_ui->findWidgetById(CCString::createWithFormat("day%d",i+1)->getCString()));
day->setString(CCString::createWithFormat(GETLANGSTR(209),sign.day)->getCString());
//获得字样
CImageView *getspr = (CImageView*)(m_ui->findWidgetById(CCString::createWithFormat("get%d",i+1)->getCString()));
//已领取
if (sign.status==1)
{
//宝箱变灰
mask->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
//加对勾
getspr->setVisible(true);
}
//未领取
else if(sign.status==2)
{
//宝箱变灰
mask->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
//加对勾
getspr->setVisible(false);
}
}
}
示例14: initSpandAndCheckBox
void CSmeltArmor::initSpandAndCheckBox()
{
CCSprite *coin = (CCSprite *)(m_ui->findWidgetById("coin"));
coin->setVisible(true);
//m_coin = m_armor.useLevel *360;
m_diamond = 0;
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;
}
CCSprite *diamond = (CCSprite *)(m_ui->findWidgetById("diamond"));
diamond->setVisible(false);
CLabel *money = (CLabel *)(m_ui->findWidgetById("money"));
money->setString(ToString(m_coin));
for (unsigned int i=0; i< 4; ++i)
{
CCheckBox* checkBtn = (CCheckBox*)(m_pBaseInfo[i]->findWidgetById("check"));
checkBtn->setChecked(false);
}
}
示例15: initLogin
void LoginLayerUC::initLogin()
{
CCLOG("LoginLayerUC::initLogin");
if(m_ui!=nullptr)
{
return;
}
//播放背景音乐
PlayBackgroundMusic(BGM_Login,true);
m_ui = LoadComponent("EnterGameUC.xaml");
m_ui->setTag(1);
m_ui->setPosition(VCENTER);
m_LayoutRoot->addChild(m_ui, 2);
//自己的登陆框隐藏
m_pLoginLay = (CLayout *)m_ui->getChildByTag(10);
m_pLoginLay->setVisible(false);
//选择好的服务器列表
m_pCurrentServerUI = (CLayout *)m_ui->findWidgetById("current_server");
m_pCurrentServerUI->setVisible(true);
//默认服务器
updateSelectServer();
//服务器选区
CLayout* pLayout = (CLayout*)m_ui->findWidgetById("serverCell");
pLayout->retain();
m_ui->removeChild(pLayout);
m_pCell = pLayout;
//获取空的滑动列表Scroll
m_pTableView = (CTableView*)m_ui->findWidgetById("serverScroll");
m_pTableView->setDirection(eScrollViewDirectionVertical);
m_pTableView->setSizeOfCell(m_pCell->getContentSize());
m_pTableView->setCountOfCell(m_serverInfo.server_list().size());
m_pTableView->setBounceable(true);
m_pTableView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(LoginLayerUC::tableviewDataSource));
m_pTableView->reloadData();
//按钮打开服务器列表
CImageView* pBtnServer = (CImageView*)m_ui->findWidgetById("serverBtn");
//快速登录按钮
CButton * pQuickLogin = (CButton *)m_ui->getChildByTag(1);
pQuickLogin->setOnClickListener(this,ccw_click_selector(LoginLayerUC::onQuickLogin));
CCActionInterval *scaleSmall = CCScaleTo::create(0.9f,0.98f);
CCFadeTo *out = CCFadeTo::create(0.9f,60);
CCSpawn *spawn = CCSpawn::createWithTwoActions(scaleSmall,out);
CCActionInterval *scaleBig = CCScaleTo::create(1.2f,1.0f);
CCFadeTo *in = CCFadeTo::create(1.2f,255);
CCSpawn *spawn1 = CCSpawn::createWithTwoActions(scaleBig,in);
CCSequence *seque = CCSequence::createWithTwoActions(spawn,spawn1);
CCRepeatForever *action = CCRepeatForever::create(seque);
pQuickLogin->runAction(action);
pQuickLogin->setVisible(true);
//清除用户信息
DataCenter::sharedData()->getUser()->clear();
//版本做相对位置处理
CLabel* pLabel = (CLabel *)m_ui->findWidgetById("version");
pLabel->setAnchorPoint(ccp(1.0f, 0.0f));
pLabel->setPosition(ccp(VRIGHT-20, VBOTTOM+20));
CC_SAFE_RETAIN(pLabel);
pLabel->removeFromParentAndCleanup(true);
this->addChild(pLabel);
CC_SAFE_RELEASE(pLabel);
pLabel->setString(CCString::createWithFormat("Version:%s", m_serverInfo.game_version().c_str())->getCString());
//隐藏服务器列表
showServerList();
hideServerList();
//TODO
//初始化UC_SDK?-放在最前面
//还是点击登录再初始化?
//点击登录再初始化吧
//初始化完直接请求登录
//先连接连接服务器
const Server& gameServer = m_serverInfo.server_list().Get(m_iSelectServerIndex);
//检查服务器是否可用
if(!checkServerStatus(gameServer))
{
return;
}
LinkedGameServer(gameServer);
}