本文整理汇总了C++中UserData::getFriends方法的典型用法代码示例。如果您正苦于以下问题:C++ UserData::getFriends方法的具体用法?C++ UserData::getFriends怎么用?C++ UserData::getFriends使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserData
的用法示例。
在下文中一共展示了UserData::getFriends方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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)));
}
示例2: updateRoleProperty
void CTopLayer::updateRoleProperty(const TMessage& tMsg)
{
UserData *user = DataCenter::sharedData()->getUser()->getUserData();
CCScaleTo* sc1 = CCScaleTo::create(0.15f,1.3f);
CCScaleTo* sc2 = CCScaleTo::create(0.35f,1.0f);
CCSequence* sqes = CCSequence::create(sc1,sc2,nullptr);
if (user->getCoin()!=atoi(m_coinLabel->getString()))
{
CProgressLabel *prolab = CProgressLabel::create();
prolab->setLabel(m_coinLabel);
prolab->changeValueTo(user->getCoin(),0.5f);
CCSequence* sqes1 = (CCSequence*)sqes->copy();
m_coinLabel->runAction(sqes1);
this->addChild(prolab);
CLabel *label = (CLabel*)m_ui->getChildByTag(130);
int coin = user->getCoin()-atoi(m_coinLabel->getString());
changeLabel(label, coin);
}
if (user->getRoleGold()!=atoi(m_moneyLabel->getString()))
{
CProgressLabel *prolab = CProgressLabel::create();
prolab->setLabel(m_moneyLabel);
prolab->changeValueTo(user->getRoleGold(),0.5f);
CCSequence* sqes1 = (CCSequence*)sqes->copy();
m_moneyLabel->runAction(sqes1);
this->addChild(prolab);
CLabel *label = (CLabel*)m_ui->getChildByTag(140);
int coin = user->getRoleGold()-atoi(m_moneyLabel->getString());
changeLabel(label, coin);
}
/*
if (user->getRoleFood()!=atoi(m_foodLabel->getString()))
{
CProgressLabel *prolab = CProgressLabel::create();
prolab->setLabel(m_foodLabel);
prolab->changeValueTo(user->getRoleFood(),0.5f);
CCSequence* sqes1 = (CCSequence*)sqes->copy();
m_foodLabel->runAction(sqes1);
this->addChild(prolab);
CLabel *label = (CLabel*)m_ui->getChildByTag(170);
int coin = user->getRoleFood()-atoi(m_foodLabel->getString());
changeLabel(label, coin);
}
*/
if (user->getFriends()!=atoi(m_foodLabel->getString()))
{
CProgressLabel *prolab = CProgressLabel::create();
prolab->setLabel(m_foodLabel);
prolab->changeValueTo(user->getFriends(),0.5f);
CCSequence* sqes1 = (CCSequence*)sqes->copy();
m_foodLabel->runAction(sqes1);
this->addChild(prolab);
CLabel *label = (CLabel*)m_ui->getChildByTag(170);
int coin = user->getFriends()-atoi(m_foodLabel->getString());
changeLabel(label, coin);
}
CLabel *action = (CLabel*)(m_ui->findWidgetById("action"));
if (user->getRoleAction()!=atoi(action->getString()))
{
CCSequence* sqes2 = (CCSequence*)sqes->copy();
action->runAction(sqes2);
action->setString(CCString::createWithFormat("%d/%d",user->getRoleAction(), user->getActionLimit())->getCString());
}
}