本文整理汇总了C++中Enemy::getHP方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::getHP方法的具体用法?C++ Enemy::getHP怎么用?C++ Enemy::getHP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::getHP方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onHeroAttack
void GameLayer::onHeroAttack()
{
if(m_pHero->isLive())
{
m_pHero->runAttackAction();
if(m_pHero->getCurrActionState() == ACTION_STATE_ATTACK)
{
Object *enemyObj = NULL;
CCARRAY_FOREACH(m_pEnemies, enemyObj)
{
Enemy *pEnemy = (Enemy*)enemyObj;
if(pEnemy->getCurrActionState() >= ACTION_STATE_DEAD)
{
continue;
}
if(fabsf(m_pHero->getPosition().y - pEnemy->getPosition().y) < 10)
{
BoundingBox heroHitBox = m_pHero->getHitBox();
BoundingBox enemyBodyBox = pEnemy->getBodyBox();
if(::collisionDetection(heroHitBox, enemyBodyBox))
{
int damage = m_pHero->getAttack();
pEnemy->runHurtAction();
pEnemy->setHP(pEnemy->getHP() - damage);
if(pEnemy->getHP() <= 0)
{
pEnemy->runDeadAction();
}
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(PATH_HERO_HIT_EFFECT);
}
}
}
示例2:
Enemy::Enemy(Enemy const &obj)
{
this->_type = obj.getType();
this->_hp = obj.getHP();
}