当前位置: 首页>>代码示例>>C++>>正文


C++ Enemy::getBodyBox方法代码示例

本文整理汇总了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);
					}
				}
			}
开发者ID:Michael-Z,项目名称:PompaDroid,代码行数:36,代码来源:GameLayer.cpp

示例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);
					
				}
			}
		}
	}
开发者ID:AS3ECoder,项目名称:Chaos,代码行数:89,代码来源:Hero.cpp


注:本文中的Enemy::getBodyBox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。