本文整理汇总了C++中Enemy::getBodyBox方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::getBodyBox方法的具体用法?C++ Enemy::getBodyBox怎么用?C++ Enemy::getBodyBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::getBodyBox方法的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: normalAttackCallBackAction
void Hero::normalAttackCallBackAction(Node* pSender)
{
/*
//play sound effect
if (this->currActionState == ACTION_STATE_NOMAL_ATTACK_A ||
this->currActionState == ACTION_STATE_NOMAL_ATTACK_B ||
this->currActionState == ACTION_STATE_NOMAL_ATTACK_C ||
this->currActionState == ACTION_STATE_NOMAL_ATTACK_D )
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("Sound/BladeBig2.mp3");
*/
__Array *pEnemies;
if (global->sceneInfoVector[global->sceneIndex]->bossFormatStr == NULL)
{
pEnemies = global->enemies;
}
else
{
pEnemies = global->bosses;
}
Ref *enemyObj = NULL;
Size visibleSize = Director::getInstance()->getVisibleSize();
//判断是否可以放大招
if (this->getCurrMagicPoint() >= 100)
{
addUltimateSkill();
this->setCurrMagicPoint(0.0f);
}
CCARRAY_FOREACH(pEnemies, enemyObj)
{
Enemy *pEnemy = (Enemy*)enemyObj;
if (fabsf(this->getPosition().y - pEnemy->getPosition().y < 20))
{
Rect attackRect = m_hitBox.actual;//英雄攻击区域
Rect hurtRect = pEnemy->getBodyBox().actual;//怪物受伤区域
if (attackRect.intersectsRect(hurtRect))
{
pEnemy->setAllowMove(false);
//此处可处理怪物被攻击后的后续,产生伤害数字
int damage = random(this->getDamageStrength()*0.7, this->getDamageStrength()*1.3);
hitCounter();
Vec2 point = pEnemy->getBodyBox().actual.origin;
damageDisplay(damage, Vec2(point.x , point.y + 80));
pEnemy->runHurtAction();
enemyBloodDisplay(Vec2(point.x-10,point.y-10));
if (this->getCurrActionState() == ACTION_STATE_NOMAL_ATTACK_C || this->getCurrActionState() == ACTION_STATE_NOMAL_ATTACK_D)
{
if (getRoleDirection())
{
pEnemy->setFlippedX(false);
pEnemy->runHurtFlyLeftAction();
}
else
{
pEnemy->setFlippedX(true);
pEnemy->runHurtFlyRightAction();
}
}
//pEnemy->runHurtFlyLeftAction();
if (hitCount > 1)
{
combosDisplay(hitCount, Vec2(visibleSize.width *0.15, visibleSize.height * 0.75));
}
pEnemy->setCurtLifeValue(pEnemy->getCurtLifeValue() - damage);
if (pEnemy->getCurtLifeValue() <= 0)
{
pEnemy->runDeadAction();
pEnemy->setBodyBox(createBoundingBox(Vec2::ZERO, Size::ZERO));
pEnemy->setOpacity(124);
float temp = this->getPosition().x - visibleSize.width / 2;
float destX = (temp > 0) ? temp : 0;
addDeadFire(Vec2(destX,visibleSize.height) ,pEnemy->getPosition());
pEnemy->setVisible(false);
}
}
}
}