本文整理汇总了C++中UILabel::setVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ UILabel::setVisible方法的具体用法?C++ UILabel::setVisible怎么用?C++ UILabel::setVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UILabel
的用法示例。
在下文中一共展示了UILabel::setVisible方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onEnter
void TartarLayer::onEnter()
{
CCLayer::onEnter();
UiManager::Singleton().Init(this);
UiManager::Singleton().SetupWidget("../UIProject/Json/Tartar.json");
UIWidget* pUIWidget = UiManager::Singleton().GetChildByName("Panel1");
pUIWidget->setVisible(true);
pUIWidget = UiManager::Singleton().GetChildByName("Panel2");
pUIWidget->setVisible(false);
UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_Warning"));
pUILabel->setVisible(false);
pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_DayDiff"));
pUILabel->setVisible(false);
pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_PastDay"));
pUILabel->setVisible(false);
UITextField* pUITextField = DynamicCast<UITextField*>(UiManager::Singleton().GetChildByName("TextField_Year"));
pUITextField->setMaxLengthEnable(true);
pUITextField->setMaxLength(4);
pUITextField->addInsertTextEvent(this, coco_TextFieldInsertTextSelector(TartarLayer::TextFieldInserted));
pUITextField = DynamicCast<UITextField*>(UiManager::Singleton().GetChildByName("TextField_Mon"));
pUITextField->setMaxLengthEnable(true);
pUITextField->setMaxLength(2);
pUITextField->addInsertTextEvent(this, coco_TextFieldInsertTextSelector(TartarLayer::TextFieldInserted));
pUITextField = DynamicCast<UITextField*>(UiManager::Singleton().GetChildByName("TextField_Day"));
pUITextField->setMaxLengthEnable(true);
pUITextField->setMaxLength(2);
pUITextField->addInsertTextEvent(this, coco_TextFieldInsertTextSelector(TartarLayer::TextFieldInserted));
UIButton* pButton = DynamicCast<UIButton*>(UiManager::Singleton().GetChildByName("TextButton_Start"));
pButton->addReleaseEvent(this, coco_releaseselector(TartarLayer::BottonOKClicked));
pButton = DynamicCast<UIButton*>(UiManager::Singleton().GetChildByName("TextButton_Finish"));
pButton->addReleaseEvent(this, coco_releaseselector(TartarLayer::BottonFinishClicked));
pButton = DynamicCast<UIButton*>(UiManager::Singleton().GetChildByName("TextButton_Order"));
pButton->addReleaseEvent(this, coco_releaseselector(TartarLayer::BottonOrderClicked));
UILabel* pUILabelWarning = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_NeedCheck"));
pUILabelWarning->setVisible(false);
UIImageView* pImage = DynamicCast<UIImageView*>(UiManager::Singleton().GetChildByName("ImageView"));
CCRect rect = pImage->getRect();
float normalWidth = cocos2d::CCEGLView::sharedOpenGLView()->getDesignResolutionSize().width - 10.0f;
float normalHeight = normalWidth * 0.6f;
pImage->setScaleX(normalWidth / rect.size.width * pImage->getScaleX());
pImage->setScaleY(normalHeight / rect.size.height * pImage->getScaleY());
}
示例2: processItemExchangeFunc
void TaskChatLayer::processItemExchangeFunc(bool visible)
{
UIButton* btnLeft = taskChatLayout->FindChildObjectByName<UIButton>("ItemExchangShopBtn");
UILabel* labelLeft = taskChatLayout->FindChildObjectByName<UILabel>("ItemExchangText");
btnLeft->setVisible(visible);
labelLeft->setVisible(visible);
labelLeft->setString(Localizatioin::getLocalization("M_EXCHANGESHOP_TITLE"));
UIButton* btnRight = taskChatLayout->FindChildObjectByName<UIButton>("CityDefendBtn");
UILabel* labelRight = taskChatLayout->FindChildObjectByName<UILabel>("CityDefendText");
btnRight->setVisible(visible);
labelRight->setVisible(visible);
labelRight->setString(Localizatioin::getLocalization("M_CITYDEFEND_TITLE"));
mShopType = 8;
}
示例3: Show
void KHeroLevUpResultPanel::Show(const KHeroDef& oldHero,const KHeroDef& newHero)
{
m_bPlay = true;
if(!m_Panel->getParent()) m_layer->addWidget(m_Panel);
m_oldHero = oldHero;
m_newHero = newHero;
m_elapsed = 0.0f;
CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(KHeroLevUpResultPanel::DoClose),this,6,0,0.0f,false);
char sz[64];
UILabel* labelOldStrong = (UILabel*)m_Panel->getChildByName("old_strong_val");
sprintf(sz,"%d",oldHero.GetStrong());
labelOldStrong->setText(sz);
UIWidget* strongTo = m_Panel->getChildByName("strong_to");
UILabel* labelNewStrong = (UILabel*)m_Panel->getChildByName("new_strong_val");
strongTo->setVisible(false);
labelNewStrong->setVisible(false);
sprintf(sz,"%d",newHero.GetStrong());
labelNewStrong->setText(sz);
UILabel* labelOldLucky = (UILabel*)m_Panel->getChildByName("old_lucky_val");
sprintf(sz,"%d",oldHero.GetLucky());
labelOldLucky->setText(sz);
UIWidget* luckyTo = m_Panel->getChildByName("lucky_to");
UILabel* labelNewLucky = (UILabel*)m_Panel->getChildByName("new_lucky_val");
sprintf(sz,"%d",newHero.GetLucky());
labelNewLucky->setText(sz);
luckyTo->setVisible(false);
labelNewLucky->setVisible(false);
m_pNewSkill = NULL;
for(int i=0; i<MAX_HERO_SKILL_NUM; i++) {
if(newHero._skill[i]._id>0 &&
oldHero._skill[i]._id==0) {
m_pNewSkill = &newHero._skill[i];
break;
}
}
UILabel* lableSkill = (UILabel*)m_Panel->getChildByName("skill_name");
lableSkill->setVisible(false);
if(m_pNewSkill) {
lableSkill->setText(m_pNewSkill->GetName());
}
for(int i=0; i<MAX_HERO_LEV_NUM; i++) {
UIWidget* widgetStar = KUIAssist::GetIndexWidget(m_Panel,"star",i);
widgetStar->setVisible(false);
}
}
示例4: processGuildChat
void TaskChatLayer::processGuildChat(int type, bool visible)
{
UIButton* btnLeft = taskChatLayout->FindChildObjectByName<UIButton>("ItemExchangShopBtn");
UILabel* labelLeft = taskChatLayout->FindChildObjectByName<UILabel>("ItemExchangText");
btnLeft->setVisible(visible);
labelLeft->setVisible(visible);
// type 10 11 12 13 分别代表公会商人、祈福、活动、排行
if(type == 10)
{
labelLeft->setString(Localizatioin::getLocalization("G_SHOP_TITLE"));
}
else if(type == 11)
{
labelLeft->setString(Localizatioin::getLocalization("G_BENEDICTION_TITLE"));
}
else if(type == 12)
{
labelLeft->setString(Localizatioin::getLocalization("G_INSTANCE"));
}
else if(type == 13)
{
labelLeft->setString(Localizatioin::getLocalization("G_RANK"));
}
mShopType = type;
}
示例5: update
void KHeroLevUpResultPanel::update(float dt)
{
m_elapsed += dt;
if(m_elapsed<4.0f && m_bPlay) {
if(m_elapsed >0.6f) {
UIWidget* strongTo = m_Panel->getChildByName("strong_to");
if(m_newHero.GetStrong()>m_oldHero.GetStrong()) {
strongTo->setVisible(true);
}
UIWidget* luckyTo = m_Panel->getChildByName("lucky_to");
if(m_newHero.GetLucky()>m_oldHero.GetLucky()) {
luckyTo->setVisible(true);
}
}
if(m_elapsed >1.2f) {
UILabel* labelNewStrong = (UILabel*)m_Panel->getChildByName("new_strong_val");
if(m_newHero.GetStrong()>m_oldHero.GetStrong()) {
labelNewStrong->setVisible(true);
}
UILabel* labelNewLucky = (UILabel*)m_Panel->getChildByName("new_lucky_val");
if(m_newHero.GetLucky()>m_oldHero.GetLucky()) {
labelNewLucky->setVisible(true);
}
}
if(m_elapsed >1.8f) {
if(m_pNewSkill) {
UILabel* lableSkill = (UILabel*)m_Panel->getChildByName("skill_name");
lableSkill->setVisible(true);
}
}
int starNum = m_newHero.GetLev();
float interval = 2.0f / (float)m_newHero.GetLev() ;
int curStarNum = (m_elapsed>=2.0f)?m_newHero.GetLev(): m_elapsed/interval;
for(int i=0; i<MAX_HERO_LEV_NUM; i++) {
UIWidget* widgetStar = KUIAssist::GetIndexWidget(m_Panel,"star",i);
if(i<curStarNum) {
widgetStar->setVisible(true);
} else {
widgetStar->setVisible(false);
}
}
}
}
示例6: TextFieldInserted
void TartarLayer::TextFieldInserted( CCObject* pSender )
{
UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_Warning"));
pUILabel->setVisible(false);
UITextField* pUITextField = DynamicCast<UITextField*>(pSender);
std::string str = pUITextField->getStringValue();
if (str.size() > 0)
{
char lastLetter = str[str.size()-1];
if (lastLetter < '0' || lastLetter > '9')
{
str.pop_back();
pUITextField->setText(str.c_str());
}
}
}
示例7: onEnter
void LoginLayer::onEnter()
{
TextFieldTTFLayer::onEnter();
// UI setup
UiManager::Singleton().Init(this);
UiManager::Singleton().SetupWidget("../UIProject/Json/Login.json");
UIButton* pButton = DynamicCast<UIButton*>(UiManager::Singleton().GetChildByName("TextButton_OK"));
pButton->addReleaseEvent(this, coco_releaseselector(LoginLayer::BottonOKClicked));
pButton = DynamicCast<UIButton*>(UiManager::Singleton().GetChildByName("TextButton_Yes"));
pButton->addReleaseEvent(this, coco_releaseselector(LoginLayer::BottonYesClicked));
pButton = DynamicCast<UIButton*>(UiManager::Singleton().GetChildByName("TextButton_No"));
pButton->addReleaseEvent(this, coco_releaseselector(LoginLayer::BottonNoClicked));
UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_Fail"));
pUILabel->setVisible(false);
UIWidget* pUIWidget = UiManager::Singleton().GetChildByName("Panel_LoginConfirm");
pUIWidget->setVisible(false);
}
示例8: BottonOKClicked
void TartarLayer::BottonOKClicked( CCObject* pSender )
{
// Check date Format is correct or not
bool dateFormatIsValid = true;
UITextField* pUITextField = DynamicCast<UITextField*>(UiManager::Singleton().GetChildByName("TextField_Year"));
int year = atoi(pUITextField->getStringValue());
int mon = 0;
int day = 0;
if (year != 2013)
{
dateFormatIsValid = false;
}
if (dateFormatIsValid)
{
pUITextField = DynamicCast<UITextField*>(UiManager::Singleton().GetChildByName("TextField_Mon"));
mon = atoi(pUITextField->getStringValue());
if (mon < 1 || mon > 12)
{
dateFormatIsValid = false;
}
}
if (dateFormatIsValid)
{
pUITextField = DynamicCast<UITextField*>(UiManager::Singleton().GetChildByName("TextField_Day"));
day = atoi(pUITextField->getStringValue());
if (day < 1 || day > 31)
{
dateFormatIsValid = false;
}
}
if (!dateFormatIsValid)
{
UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_Warning"));
pUILabel->setVisible(true);
}
else
{
// Get Current Date
tm curTime = GetDate();
curTime.tm_hour = 0;
curTime.tm_min = 0;
curTime.tm_sec = 0;
tm inputTime;
inputTime.tm_year = year;
inputTime.tm_mon = mon;
inputTime.tm_mday = day;
int dayDiff = GetElapseDayNum(curTime, inputTime);
if (dayDiff < 0)
{
UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_Warning"));
pUILabel->setVisible(true);
}
else
{
UIWidget* pUIWidget = UiManager::Singleton().GetChildByName("Panel1");
pUIWidget->setVisible(false);
pUIWidget = UiManager::Singleton().GetChildByName("Panel2");
pUIWidget->setVisible(true);
UILabel* pUILabelDayDiff = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_DayDiff"));
char str[10];
sprintf(str,"%d",dayDiff);
pUILabelDayDiff->setText(str);
pUILabelDayDiff->setVisible(true);
pUILabelDayDiff = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_PastDay"));
pUILabelDayDiff->setVisible(true);
// Request info according the diffDay.
CCHttpRequest* request = new CCHttpRequest();
std::string url = "http://localhost:8000/plaque/" + std::string(str);
request->setUrl(url.c_str());
request->setRequestType(CCHttpRequest::kHttpGet);
request->setResponseCallback(this, httpresponse_selector(TartarLayer::onHttpRequestCompleted));
request->setTag("GET INFO");
CCHttpClient::getInstance()->send(request);
request->release();
}
}
}
示例9: onHttpRequestCompleted
void TartarLayer::onHttpRequestCompleted(CCHttpClient *sender, CCHttpResponse *response)
{
if (!response)
{
return;
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
CCLog("response code: %d", statusCode);
if (!response->isSucceed())
{
CCLog("response failed");
CCLog("error buffer: %s", response->getErrorBuffer());
return;
}
// dump data
std::vector<char> *buffer = response->getResponseData();
std::string bufferStr(buffer->begin(),buffer->end());
if (std::string(response->getHttpRequest()->getTag()) == std::string("GET INFO"))
{
// Display the memberId and name.
cJSON* json;
json = cJSON_Parse(bufferStr.c_str());
if (json)
{
cJSON* messageJSON = cJSON_GetObjectItem(json, "message");
if (messageJSON)
{
// Set NeedCheck label
UILabel* pUILabelWarning = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_NeedCheck"));
pUILabelWarning->setVisible(true);
pUILabelWarning->setText(messageJSON->valuestring);
}
cJSON* imageJSON = cJSON_GetObjectItem(json, "image");
if (imageJSON)
{
std::string imagePath = imageJSON->valuestring;
CCHttpRequest* request = new CCHttpRequest();
std::string url = "http://localhost:8000/media/" + imagePath;
request->setUrl(url.c_str());
request->setRequestType(CCHttpRequest::kHttpGet);
request->setResponseCallback(this, httpresponse_selector(TartarLayer::onHttpRequestCompleted));
request->setTag("GET IMAGE");
CCHttpClient::getInstance()->send(request);
request->release();
int index = imagePath.find_last_of(".");
if (index != -1)
{
m_textureFormat = imagePath.substr(index);
}
}
}
}
else
{
std::string path = CCFileUtils::sharedFileUtils()->getWritablePath();
// Save it locally
path += "currentTeeth";
path += m_textureFormat;
CCLOG("path: %s",path.c_str());
FILE *fp = fopen(path.c_str(), "wb+");
fwrite(bufferStr.c_str(), 1,buffer->size(), fp);
fclose(fp);
// Display
UIImageView* pImage = DynamicCast<UIImageView*>(UiManager::Singleton().GetChildByName("ImageView"));
pImage->setTexture(path.c_str());
CCRect rect = pImage->getRect();
float normalWidth = cocos2d::CCEGLView::sharedOpenGLView()->getDesignResolutionSize().width - 10.0f;
float normalHeight = normalWidth * 0.6f;
pImage->setScaleX(normalWidth / rect.size.width * pImage->getScaleX());
pImage->setScaleY(normalHeight / rect.size.height * pImage->getScaleY());
}
}
示例10: onHttpRequestCompleted
void LoginLayer::onHttpRequestCompleted(CCHttpClient *sender, CCHttpResponse *response)
{
if (!response)
{
UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_Fail"));
pUILabel->setVisible(true);
return;
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
CCLog("response code: %d", statusCode);
if (!response->isSucceed())
{
UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_Fail"));
pUILabel->setVisible(true);
return;
}
// Success!
// Enter next UI page
UIWidget* pUIWidget = UiManager::Singleton().GetChildByName("Panel_Login");
pUIWidget->setVisible(false);
EnableTextField(false);
pUIWidget = UiManager::Singleton().GetChildByName("Panel_LoginConfirm");
pUIWidget->setVisible(true);
UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_Fail"));
pUILabel->setVisible(false);
// Dump data
std::vector<char> *buffer = response->getResponseData();
std::string bufferStr(buffer->begin(),buffer->end());
// Display the memberId and name.
cJSON* json;
json = cJSON_Parse(bufferStr.c_str());
if (json)
{
cJSON* memberIdJSON = cJSON_GetObjectItem(json, "member_id");
if (memberIdJSON)
{
UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_NumberValue"));
pUILabel->setText(memberIdJSON->valuestring);
}
cJSON* nameJSON = cJSON_GetObjectItem(json, "name");
if (nameJSON)
{
UILabel* pUILabel = DynamicCast<UILabel*>(UiManager::Singleton().GetChildByName("Label_NameValue"));
pUILabel->setText(nameJSON->valuestring);
// Save clinic name
GameData::Singleton().SetClinicName(std::string(nameJSON->valuestring));
}
cJSON* homePageJSON = cJSON_GetObjectItem(json, "homepage");
if (homePageJSON)
{
// Save homepage Url
GameData::Singleton().SetHomePageUrl(std::string(homePageJSON->valuestring));
}
cJSON* mapPathJSON = cJSON_GetObjectItem(json, "map");
if (mapPathJSON)
{
// Save mapPath
GameData::Singleton().SetMapPath(std::string(mapPathJSON->valuestring));
}
}
}
示例11: refreshPvAILayer
void PvAIManager::refreshPvAILayer()
{
UIManager *manager = UIManager::sharedManager();
pvaiLayout = manager->getUILayout("PvAILayout");
if (pvaiLayout)
{
//玩家昵称
UILabel *heroNameLabel = pvaiLayout->FindChildObjectByName<UILabel>("pvaiMcName");
if (heroNameLabel)
{
string heroName = UserData::getUserName();
heroNameLabel->setString(heroName.c_str());
}
//玩家排名
UILabel *heroRankLabel = pvaiLayout->FindChildObjectByName<UILabel>("pvaiMcRank");
if (heroRankLabel)
{
stringstream heroRankStream;
heroRankStream << heroRank;
string heroRankStr = heroRankStream.str();
string heroRankText = Localizatioin::getLocalization("M_PVAI_RANK");
heroRankText += heroRankStr;
heroRankLabel->setString(heroRankText.c_str());
}
//玩家声望
UILabel *heroReputationLabel = pvaiLayout->FindChildObjectByName<UILabel>("pvaiMcReputation");
if (heroReputationLabel)
{
int heroReputation = UserData::GetUserInfo().m_reputation;
stringstream heroReputationStream;
heroReputationStream << heroReputation;
string heroReputationStr = heroReputationStream.str();
string heroReputationText = Localizatioin::getLocalization("M_PVAI_REPUTATION");
heroReputationText += heroReputationStr;
heroReputationLabel->setString(heroReputationText.c_str());
}
////剩余挑战次数
//UILabel *lastTimeLabel = pvaiLayout->FindChildObjectByName<UILabel>("pvaiTodayLastTime");
//if (lastTimeLabel)
//{
// stringstream herolastTimeStream;
// herolastTimeStream << basicInfo.remainCount;
// string herolastTimeStr = herolastTimeStream.str();
// lastTimeLabel->setString(herolastTimeStr.c_str());
//}
////奖励金币数
//UILabel *rewardCoinLabel = pvaiLayout->FindChildObjectByName<UILabel>("pvaiRewardCoin");
//if (rewardCoinLabel)
//{
// stringstream herolastTimeStream;
// herolastTimeStream << basicInfo.rewardCoin;
// string herolastTimeStr = herolastTimeStream.str();
// rewardCoinLabel->setString(herolastTimeStr.c_str());
//}
////奖励声望
//UILabel *rewardReputationLabel = pvaiLayout->FindChildObjectByName<UILabel>("pvaiRewardReputation");
//if (rewardReputationLabel)
//{
// stringstream herolastTimeStream;
// herolastTimeStream << basicInfo.rewardReputation;
// string herolastTimeStr = herolastTimeStream.str();
// rewardReputationLabel->setString(herolastTimeStr.c_str());
//}
////奖励领取时间
//TimeManager::Get()->renewTimer(TIMER_PVAI_REWARD, TimeManager::Get()->getCurServerTime() + basicInfo.rewardGetTime);
////冷却时间
//TimeManager::Get()->renewTimer(TIMER_PVAI_COOLDOWN, TimeManager::Get()->getCurServerTime() + basicInfo.coolDownTime);
//挑战玩家列表
int playerCount = aiPlayerVec.size();
int minPlayerCount = min(playerCount, 5);
for (int i = minPlayerCount; i < 5; i++)
{
stringstream iconOtherStream;
iconOtherStream << "iconOther" << i+1;
string iconOtherStr = iconOtherStream.str();
UIPicture *iconOtherPic= pvaiLayout->FindChildObjectByName<UIPicture>(iconOtherStr);
iconOtherPic->setVisible(false);
iconOtherStream.str("");
iconOtherStream << "gridOther" << i+1;
iconOtherStr = iconOtherStream.str();
iconOtherPic= pvaiLayout->FindChildObjectByName<UIPicture>(iconOtherStr);
iconOtherPic->setVisible(false);
iconOtherStream.str("");
iconOtherStream << "pvaiOtherPlayerName" << i+1;
iconOtherStr = iconOtherStream.str();
UILabel * iconOtherLabel= pvaiLayout->FindChildObjectByName<UILabel>(iconOtherStr);
//.........这里部分代码省略.........