本文整理汇总了C++中Fish::getCoin方法的典型用法代码示例。如果您正苦于以下问题:C++ Fish::getCoin方法的具体用法?C++ Fish::getCoin怎么用?C++ Fish::getCoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fish
的用法示例。
在下文中一共展示了Fish::getCoin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateBullet
void GameLayer::updateBullet(float dt)
{
fireBullet(dt);
Ref *pBulletObj = NULL;
CCARRAY_FOREACH(m_pBullets, pBulletObj)
{
Bullet *pBullet = (Bullet *)pBulletObj;
if (pBullet->getCaught())
continue;
bool caught = false;
bool hit = false;
for(std::vector<int>::iterator it = m_currentFish.begin();it != m_currentFish.end();it++){
int index = *it;
Fish * fish = (Fish *)this->getFishes()->getObjectAtIndex(index);
if(!fish->getVisible() && !fish->getDeleted()){
continue;
}
Rect hittestRect = shrinkRect(fish->getBounding(), 0.65f, 0.8f);
if (hittestRect.containsPoint(pBullet->getSpriteBullet()->getPosition()))
{
fish->hit(pBullet->getPower());
hit = true;
if (fish->getHP() <= 0){
caught = true;
// Add animation coin
this->addCoin(fish->getSprite()->getPositionX(),fish->getSprite()->getPositionY(),fish->getCoin(),"COMBO");
auto label = Label::create();
if(fish->getIsInstance()){
label->setTextColor(Color4B::ORANGE);
label->enableOutline(Color4B::WHITE,4);
label->setPosition(fish->getSprite()->getPosition());
label->setString(StringUtils::format("Perfect \n+ %d",fish->getCoin()));
label->setSystemFontSize(26);
}
else{
label->setTextColor(Color4B::YELLOW);
label->enableOutline(Color4B::WHITE,3);
label->setPosition(fish->getSprite()->getPosition());
label->setString(StringUtils::format("+ %d",fish->getCoin()));
label->setSystemFontSize(20);
}
label->setHorizontalAlignment(TextHAlignment::CENTER);
label->setVerticalAlignment(TextVAlignment::CENTER);
label->runAction(Sequence::create(
MoveBy::create(0.5f,Vec2(0,10)),
FadeOut::create(0.5f),
RemoveSelf::create(true),
NULL));
this->addChild(label);
int crtXP = User::Instance().getXP();
crtXP ++ ;
User::Instance().setXP(crtXP);
User::Instance().save();
this->updateXP();
fish->showCaught();
}
break;
}
}
if (caught)
{
pBullet->showNet();
}
else
{
if (hit)
{
pBullet->showSmoke();
}
}
}