本文整理汇总了C++中UserData::getCoin方法的典型用法代码示例。如果您正苦于以下问题:C++ UserData::getCoin方法的具体用法?C++ UserData::getCoin怎么用?C++ UserData::getCoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserData
的用法示例。
在下文中一共展示了UserData::getCoin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: proceesMessage
void CSmeltArmor::proceesMessage(int type, google::protobuf::Message *msg)
{
this->setVisible(true);
switch (type)
{
//洗练数据
case SmeltDataRequestMsg:
{
Armor *res = (Armor*)msg;
if(res)
{
m_armor.armor.atkRange = res->atkrange();
m_armor.armor.hpRange = res->hprange();
m_armor.armor.defRange = res->defrange();
m_armor.armor.IntRange = res->dexrange();
m_armor.armor.hitRange = res->hitrange();
m_armor.armor.critRange = res->critrange();
m_armor.armor.renewRange = res->renewrange();
m_armor.armor.dodgeRange = res->dodgerange();
showSmeltDataToUI();
}
}break;
//洗练
case SmeltArmorMsg:
{
SmeltResponse *res = (SmeltResponse*)msg;
//1 成功,2 金币不足,3 元宝不足,4 数据错误
if (res->reslut()==1)
{
//1 攻击addAtk,2 防御addDef,3 血量addHp,4 敏捷addDex,5 命中addHit,6 暴击addCrit,7 回复addRenew,8 闪避addDodge)
m_armor.armor.addAtk = res->armor().armor().addatk();
m_armor.armor.addDef = res->armor().armor().adddef();
m_armor.armor.addHp = res->armor().armor().addhp();
m_armor.armor.addDex = res->armor().armor().adddex();
m_armor.armor.addHit = res->armor().armor().addhit();
m_armor.armor.addCrit = res->armor().armor().addcrit();
m_armor.armor.addRenew = res->armor().armor().addrenew();
m_armor.armor.addDodge = res->armor().armor().adddodge();
//更新金钱
UserData *data = DataCenter::sharedData()->getUser()->getUserData();
data->setCoin(data->getCoin() - m_coin);
data->setRoleGold(data->getRoleGold() - m_diamond);
CSceneManager::sharedSceneManager()->PostMessageA(UPDATE_HERO,0,nullptr,nullptr);
CSceneManager::sharedSceneManager()->PostMessageA(UPDATE_ITEM_DATA, 2, nullptr, &m_armor);
//播放效果
float fTime = showStrengthEffect();
this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(fTime), CCCallFunc::create(this, callfunc_selector(CSmeltArmor::showArmorAttr))));
}
else if (res->reslut()==2)
{
//ShowPopTextTip(GETLANGSTR(205));
CShowToBuyResource* pShow = CShowToBuyResource::create();
pShow->showToBuyResourceByType(ShowBuyResourceCoin);
}
else if (res->reslut()==3)
{
//ShowPopTextTip(GETLANGSTR(203));
CShowToBuyResource* pShow = CShowToBuyResource::create();
pShow->showToBuyResourceByType(ShowBuyResourceGold);
}
else if (res->reslut()==4)
{
ShowPopTextTip(GETLANGSTR(170));
}
}break;
default:
break;
}
}
示例3: 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());
}
}