Пример #1
0
bool PFMPlayer::onContactBegin(cocos2d::PhysicsContact &contact)
{
    if(contact.getShapeA()->getBody() == getPhysicsBody() ||
       contact.getShapeB()->getBody() == getPhysicsBody())
    {
        PhysicsBody* other = contact.getShapeA()->getBody() == getPhysicsBody()?contact.getShapeB()->getBody() : contact.getShapeA()->getBody();
        switch (other->getTag()) {
            case PFMPhysicsBodyTypeEnemyBullet:
            {
                PFMBullet* bullet = dynamic_cast<PFMBullet*>(other->getNode());
                if(bullet != NULL)
                {
                    health -= bullet->damage;
                }
                other->getOwner()->removeFromParentAndCleanup(true);
                break;
            }
            case PFMPhysicsBodyTypeEnemy:
                other->getOwner()->removeFromParentAndCleanup(true);
                break;
            default:
                break;
        }
    }
    return true;
}
Пример #2
0
bool ContactManager::switchMoveActionAfter(const cocos2d::PhysicsContact &contact){
    int body_tag = 0;
    //找到碰撞物体
    
    if(contact.getShapeA()->getBody()->getNode()->getTag()==PROTAGONIST_TAG){
        node_Pro = contact.getShapeA()->getBody()->getNode();
        node_else =contact.getShapeB()->getBody()->getNode();
        body_tag = node_else->getTag();
    }else{
        node_Pro = contact.getShapeB()->getBody()->getNode();
        node_else = contact.getShapeA()->getBody()->getNode();
        body_tag = node_else->getTag();
    }
    
    switch((body_tag/1000)*1000){
            
        case SECTION_TAG:{
            ContactManager::onContactSeparatePro_Section();
            break;
        }
    }
    
    
    return false;
}
Пример #3
0
bool CGameLayer::onContactBegin(cocos2d::PhysicsContact &contact)
{
	PhysicsBody *a = contact.getShapeA()->getBody();
	PhysicsBody *b = contact.getShapeB()->getBody();
	contact.getShapeA()->getTag();
	if (((MASK_BALL == a->getCollisionBitmask()) &&
		(BORDER_CONTACT_BITMASK == b->getCollisionBitmask())) ||
		((MASK_BALL == b->getCollisionBitmask()) &&
			(BORDER_CONTACT_BITMASK == a->getCollisionBitmask())))
	{
		if (m_startBallMovement)
		{
			--g_gameState->m_life;
			this->removeChildByTag(TAG_BALL, true);
			m_ball.erase(m_ball.begin());
			CBall *_ball = new (std::nothrow) CBall();
			_ball->init(this, g_gameState->m_acc * g_gameState->m_level, m_player->GetPosition());
			//this->addChild(_ball);
			m_ball.push_back(_ball);
			m_startBallMovement = false;
		}
		return true;
	}

	if (((MASK_BALL == a->getCollisionBitmask()) &&
		(MASK_BLOCK == b->getCollisionBitmask())) ||
		((MASK_BALL == b->getCollisionBitmask()) &&
			(MASK_BLOCK == a->getCollisionBitmask())))
	{
		int pTag;
		if ((MASK_BALL == a->getCollisionBitmask()) && (MASK_BLOCK == b->getCollisionBitmask()))
		{
			pTag = b->getNode()->getTag();
		}
		else
		{
			pTag = a->getNode()->getTag();
		}

		int i = 0;
		for (auto it = m_blocks.begin(); it != m_blocks.end(); ++it)
		{
			if (pTag == m_blocks[i]->getTag())
			{
				playerScore();
				m_blocks[i]->del(this);
				it = m_blocks.erase(it);
				--it;
			}
			++i;
		}
		return true;
	}
	else if ((a->getCollisionBitmask() == MASK_BALL && MASK_RACKET == b->getCollisionBitmask()) || 
		(b->getCollisionBitmask() == MASK_BALL && MASK_RACKET == a->getCollisionBitmask()))
	{
		return true;
	}
	return false;
}
Пример #4
0
bool GameLayer::onContactBegin(cocos2d::PhysicsContact &contact)
{
    log("2222");
    
    if ((contact.getShapeA()->getBody()->getCategoryBitmask() & kMaskBall) == kMaskBall)
    {
        //ball do something
    }
    if ((contact.getShapeB()->getBody()->getCategoryBitmask() & kMaskBall) == kMaskBall)
    {
        //ball do something
    }
    
    if ((contact.getShapeA()->getBody()->getCategoryBitmask() & kMaskPlayer) == kMaskPlayer)
    {
        //player do something
    }
    if ((contact.getShapeB()->getBody()->getCategoryBitmask() & kMaskPlayer) == kMaskPlayer)
    {
        //player do something
    }
    
//    auto nodeA = (Sprite*)contact.getShapeA()->getBody()->getNode();
//    auto nodeB = (Sprite*)contact.getShapeB()->getBody()->getNode();
//    
//    if (nodeA == nullptr || nodeB == nullptr)
//    {
//        
//        return false;
//    }
    
    return true;
}
Пример #5
0
bool GameScene::onContactBegin( cocos2d::PhysicsContact &contact )
{
    PhysicsBody *a = contact.getShapeA()->getBody();
    PhysicsBody *b = contact.getShapeB()->getBody();
    
    if ( ( BIRD_COLLISION_BITMASK == a->getCollisionBitmask() && OBSTACLE_COLLISION_BITMASK == b->getCollisionBitmask() ) ||
        ( BIRD_COLLISION_BITMASK == b->getCollisionBitmask() && OBSTACLE_COLLISION_BITMASK == a->getCollisionBitmask() ) )
    {
        CCLOG("a :%i", a->getCollisionBitmask());
        CCLOG("b: %i", b->getCollisionBitmask() );
        CCLOG("Score: %i", score );
        CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("Sounds/Hit.mp3");
        auto scene = GameOverScene::createScene( score );
        
        Director::getInstance()->replaceScene(TransitionFade::create( TRANSITION_TIME, scene ) );

    }
    else if ( ( BIRD_COLLISION_BITMASK == a->getCollisionBitmask() && POINT_COLLISION_BITMASK == b->getCollisionBitmask() ) ||
             ( BIRD_COLLISION_BITMASK == b->getCollisionBitmask() && POINT_COLLISION_BITMASK == a->getCollisionBitmask() ) )
    {
        CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("Sounds/Point.mp3");
        
        score++;
        __String *tempScore = __String::createWithFormat( "%i", score );
        scoreLabel->setString( tempScore->getCString() );

    }
    
    return true;
}
Пример #6
0
bool BombMissile::onContactBegin(cocos2d::PhysicsContact& contact)
{
	//한 번만 데미지 입히게 하기 위한 용도. 뎀 드가고 나면 그림만 보임.
	//실제 미사일 삭제 시점은 그래픽 사라지는 시점.
	m_IsPhysics = false;

	auto bodyA = contact.getShapeA()->getBody();
	auto bodyB = contact.getShapeB()->getBody();
	auto componentA = (BaseComponent*)bodyA->getNode();
	auto componentB = (BaseComponent*)bodyB->getNode();
	BaseComponent* enemyComponent;
	bool isComponentA = true;

	if (componentA->getType() == getType())
	{
		enemyComponent = componentB;
		isComponentA = true;
	}
	else
	{
		enemyComponent = componentA;
		isComponentA = false;
	}

	GET_SOUND_MANAGER()->createSound(SoundManager::MONSTERHIT, false, getPosition());
	GET_EFFECT_MANAGER()->createEffect(ET_PUNCH_MISSILE, enemyComponent->getPosition())->enter();

	return false;
}
Пример #7
0
bool GameScene::onContactBegin(cocos2d::PhysicsContact &contact) {
	PhysicsBody *a = contact.getShapeA()->getBody();
	PhysicsBody *b = contact.getShapeB()->getBody();
	if ( (SNAKE_COLLISION_BITMASK == a->getCollisionBitmask() && FOOD_COLLISION_BITMASK == b->getCollisionBitmask()) ||
		(SNAKE_COLLISION_BITMASK == b->getCollisionBitmask() && FOOD_COLLISION_BITMASK == a->getCollisionBitmask()) ) {
		srand(time(NULL));
		auto random = rand() % 370 + 30;
		auto random2 = rand() % 270 + 30;
		auto moveTo = MoveTo::create(0, Vec2(random, random2));
		food->runAction(moveTo);

		int tempX = snakeParts.back()->getPositionX();
		int tempY = snakeParts.back()->getPositionY();
		Sprite* tempSprite = Sprite::create("snake.png");
		switch (direction) {
		case LEFT:
			tempSprite->setPosition(tempX + 10, tempY);
			break;
		case RIGHT:
			tempSprite->setPosition(tempX - 10, tempY);
			break;
		case UP:
			tempSprite->setPosition(tempX, tempY + 10);
			break;
		case DOWN:
			tempSprite->setPosition(tempX, tempY - 10);
			break;
		}

		this->addChild(tempSprite);
		snakeParts.push_back(tempSprite);
	}
	return true;
}
Пример #8
0
bool MonsterDevil::onContactBegin(cocos2d::PhysicsContact& contact)
{
	auto bodyA = contact.getShapeA()->getBody();
	auto bodyB = contact.getShapeB()->getBody();
	auto componentA = (BaseComponent*)bodyA->getNode();
	auto componentB = (BaseComponent*)bodyB->getNode();
	BaseComponent* enemyComponent;
	bool isComponentA = true;


	//어떤것 끼리 부딪혔는지는 안가르쳐주기 때문에
	//여기서 어느쪽이 monsterDevil인지 밝혀낸다.
	if (componentA->getType() == getType())
	{
		enemyComponent = componentB;
		isComponentA = true;
	}
	else
	{
		enemyComponent = componentA;
		isComponentA = false;
	}


	//FLOOR 충돌 무시 
	if (enemyComponent->getType() == OT_FLOOR)
	{
		return false;
	}

	//미사일이랑 충돌 처리
	if (enemyComponent->getPhysicsBody()->getCategoryBitmask() == PHYC_MISSILE)
	{
		Missile* missile = static_cast<Missile*>(enemyComponent);

		//수류탄은 뎀 안 입음
		if (missile->getType() == OT_MISSILE_GRENADE)
		{
			return false;
		}

		//몹이 쏜 건 안 맞음.
		if (!missile->isPlayerMissile())
		{
			return false;
		}

		float damage = missile->getDamage();

		m_Info.m_CurrentHp -= damage * 100 / (100 + m_Info.m_DefensivePower);

		//사망
		if (m_Info.m_CurrentHp <= 0)
		{
			m_IsDead = true;
		}
	}
	return true;
}
Пример #9
0
bool LevelThree::onContactBegin(cocos2d::PhysicsContact &contact)
{
	PhysicsBody* a = contact.getShapeA()->getBody();
	PhysicsBody* b = contact.getShapeB()->getBody();

	//On contact between player and any enemy, spike, or laser. Kill player. Check Lives. Run reset/Game Over.

	return true;
}
Пример #10
0
    static bool ContactDetect(cocos2d::PhysicsContact & contact, cocos2d::Layer * layer, int * score)
    {
        cocos2d::Node * nodeA = contact.getShapeA()->getBody()->getNode();
        cocos2d::Node * nodeB = contact.getShapeB()->getBody()->getNode();

        if (nodeA && nodeB)
        {
            int maskA = nodeA->getPhysicsBody()->getContactTestBitmask();
            int maskB = nodeB->getPhysicsBody()->getContactTestBitmask();

            switch (maskA | maskB)
            {
                case 0b0101 :
                {
                    // EnemyFighter with Fighter
                    Fighter * fighter = ((maskA == 0b0100) ? (Fighter *)nodeA : (Fighter *)nodeB);
                    EnemyFighter * enemy = ((maskA == 0b0001) ? (EnemyFighter *)nodeA : (EnemyFighter *)nodeB);
                    FighterWithEnemy(fighter, enemy, score);
                    break;
                }
                case 0b0110 :
                {
                    // EnemyBullet with Fighter
                    Fighter * fighter;
                    EnemyBullet * bullet;
                    if (maskA == 0b0100)
                    {
                        fighter = dynamic_cast<Fighter *>(nodeA);
                        bullet = dynamic_cast<EnemyBullet *>(nodeB);
                    }
                    else
                    {
                        fighter = dynamic_cast<Fighter *>(nodeB);
                        bullet = dynamic_cast<EnemyBullet *>(nodeA);
                    }

                    FighterWithBullet(fighter, bullet, score);
                    break;
                }
                case 0b1001 :
                {
                    // Bullet with EnemyFighter
                    EnemyFighter * enemy = ((maskA == 0b0001) ? (EnemyFighter *)nodeA : (EnemyFighter *)nodeB);
                    Bullet * bullet = ((maskA == 0b1000) ? (Bullet *)nodeA : (Bullet *)nodeB);
                    EnemyWithBullet(enemy, bullet, layer, score);
                    break;
                }
                    
                default:
                    break;
            }
        }



        return false;
    }
Пример #11
0
bool ContactManager::switchMoveAction(const cocos2d::PhysicsContact &contact){
    int body_tag = 0;
    //找到碰撞物体
   
    if(contact.getShapeA()->getBody()->getNode()->getTag()==PROTAGONIST_TAG){
        node_Pro = contact.getShapeA()->getBody()->getNode();
        node_else =contact.getShapeB()->getBody()->getNode();
        body_tag = node_else->getTag();
    }else{
        node_Pro = contact.getShapeB()->getBody()->getNode();
        node_else = contact.getShapeA()->getBody()->getNode();
        body_tag = node_else->getTag();
    }
    
    switch((body_tag/1000)*1000){
        case SECTION_TAG:{
            ContactManager::onContactBeginPro_Section();
            break;
        }
        case JAILER_TAG:{
            ContactManager::onContactBeginPro_Jailer();
            break;
        }
        case MOUSE_TAG:{
            ContactManager::onContactBeginPro_Mouse();
            break;
        }
        case COIN_TAG:{
            ContactManager::onContactBeginPro_Coin();
            break;
        }
        case WALL_TAG:{
            ContactManager::onContactBeginPro_Wall();
            break;
        }
        case SECTION_END_TAG:{
            ContactManager::onContactBeginPro_End();
            break;
        }
    }
    
    
    return false;
}
Пример #12
0
void LevelThree::onContactSeperate(cocos2d::PhysicsContact &contact)
{
	PhysicsBody* a = contact.getShapeA()->getBody();
	PhysicsBody* b = contact.getShapeB()->getBody();

	if (1 == a->getCollisionBitmask() || 1 == b->getCollisionBitmask())
	{

	}
}
Пример #13
0
bool GameLayer::onContactBegin(cocos2d::PhysicsContact& contact)
{
    auto bodyA = contact.getShapeA()->getBody();
    auto bodyB = contact.getShapeB()->getBody();
    auto componentA = static_cast<BaseComponent*>( bodyA->getNode() );
    auto componentB = static_cast<BaseComponent*>( bodyB->getNode() );
    bool resA = componentA->onContactBegin(contact);
    bool resB = componentB->onContactBegin(contact);

    return resA && resB;
}
Пример #14
0
bool LevelThree::onContactPreSolve(cocos2d::PhysicsContact &contact, cocos2d::PhysicsContactPreSolve& solve)
{
	PhysicsBody* a = contact.getShapeA()->getBody();
	PhysicsBody* b = contact.getShapeB()->getBody();

	if (1 == a->getCollisionBitmask() || 1 == b->getCollisionBitmask())
	{
		solve.setRestitution(0);
	}

	return true;
}
Пример #15
0
/** 碰撞开始事件
 *  @2015/12/28 14:40
 */
bool guaiwu_js::onCollisionBegin(const cocos2d::PhysicsContact& contact)
{
    PhysicsBody* bodyA = contact.getShapeA()->getBody();
    PhysicsBody* bodyB = contact.getShapeB()->getBody();
    PhysicsBody* temp =nullptr;
    log("弹簧  A:%d B:%d",bodyA->getTag(),bodyB->getTag());
    if(bodyA->getTag() == 400001){
        temp = bodyB;
        bodyB = bodyA;
        bodyA = temp;
    }
    if(bodyB->getTag() == 400001)
    {
        if (bodyA->getTag() ==400008)
        {
            //设置怪物 停止移动
            isMove =false;
            //切换动画吃东西
            this->removeFromParent();
        }
        
        if (bodyA->getTag() == 400010) {
            this->iskeyl = !this->iskeyl;
            this->iskeyr = !this->iskeyr;
            this->setScaleX(-this->getScaleX());
            log("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
        }
        
        switch (bodyA->getTag()) {
            case 400006:
                if (bodyA->getNode() !=nullptr)
                {
                    bodyA->getNode()->removeFromParent();
                }
                setEat();
                break;
            case 555555:
                //僵死碰到车
                guaiwu_js::killcar();
                
                break;
                
            case 600001:
                
                break;
                
            default:
                break;
        }
    }
    
    return true;
}
Пример #16
0
/** 碰撞开始事件
 *  @2015/12/16 11:28
 */
bool Level_1::onCollisionBegin(const cocos2d::PhysicsContact& contact)
{
    PhysicsBody* bodyA = contact.getShapeA()->getBody();
    PhysicsBody* bodyB = contact.getShapeB()->getBody();
    PhysicsBody* temp =nullptr;
    //log("A:%d B:%d",bodyA->getTag(),bodyB->getTag());
    if(bodyA->getTag() == 555555)
    {
        temp = bodyB;
        bodyB = bodyA;
        bodyA = temp;
        
    }

    if(bodyB->getTag() == 555555)
    {
        //log("A:%d",bodyA->getTag());
        //  100001     物理世界
        //  555555     主要车的
        //  300001     悬浮的物体
        //  400001     第一关的怪物
        //  600001     弹簧的物体
        
        
        if (bodyA->getTag()== 400001)
        {
            MainCar_R* car =(MainCar_R*)bodyB->getNode()->getParent()->getParent();
            //car->removeFromParent();
            car->setBodyEnable();
        }
        
        switch (bodyA->getTag()) {
            case 400001:
                log("第一关的怪物");
                bodyB->setEnabled(false);

                break;
                
            case 300001:
                log("悬浮的物体");
                break;
            
            case 600001:
                log("弹簧的物体");
                break;
                
            default:
                break;
        }
    }

    return true;
}
Пример #17
0
bool UT_Map::onContactBegan(cocos2d::PhysicsContact &contact){
    auto nodeA = contact.getShapeA()->getBody()->getNode();
    auto nodeB = contact.getShapeB()->getBody()->getNode();
    
//    cocos2d::log( " nodeA name  %s" , nodeA->getName().c_str() );
//    cocos2d::log( " nodeB name  %s" , nodeB->getName().c_str() );
    
    if( nodeA == body || nodeB == body){
        body_move_r = !body_move_r;
    }else{
//        cocos2d::log( " can not match ");
    }
    
    return true;
}
Пример #18
0
bool GameScene::onContactBegin( cocos2d::PhysicsContact &contact )
{
	if(gameState == 1)
	{
		PhysicsBody *a = contact.getShapeA()->getBody();
		PhysicsBody *b = contact.getShapeB()->getBody();

		if ((BIRD_COLLISION_BITMASK == a->getCollisionBitmask() && OBSTACLE_COLLISION_BITMASK == b->getCollisionBitmask()) || (BIRD_COLLISION_BITMASK == b->getCollisionBitmask() && OBSTACLE_COLLISION_BITMASK == a->getCollisionBitmask()))
		{
			hit();
		}
	}

	return true;
}
Пример #19
0
void GameLayer::onContactSeparate(cocos2d::PhysicsContact& contact)
{
    auto bodyA = contact.getShapeA()->getBody();
    auto bodyB = contact.getShapeB()->getBody();
    auto componentA = static_cast<BaseComponent*>( bodyA->getNode() );
    auto componentB = static_cast<BaseComponent*>( bodyB->getNode() );

    if (componentA != nullptr)
    {
        componentA->onContactSeparate(contact);
    }
    if (componentB != nullptr)
    {
        componentB->onContactSeparate(contact);
    }
}
Пример #20
0
bool HelloWorld::onContactBegin(cocos2d::PhysicsContact &contact) {
	PhysicsBody *a = contact.getShapeA()->getBody();
	PhysicsBody *b = contact.getShapeB()->getBody();
	if ((1 == a->getCollisionBitmask() && 2 == b->getCollisionBitmask()) || (2 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())) {
		auto spriteA = (Sprite*)a->getNode();
		auto spriteB = (Sprite*)b->getNode();
		if (2 == b->getCollisionBitmask()) {
			this->removeChild(spriteB, true);
			score++;
		} else if (2 == a->getCollisionBitmask()) {
			this->removeChild(spriteA, true);
			score++;
		}
	}
	return true;
}
Пример #21
0
void SinglePlayerScene::onContactSeparate(cocos2d::PhysicsContact &contact)
{
    auto nodeA = contact.getShapeA()->getBody()->getNode();
    auto nodeB = contact.getShapeB()->getBody()->getNode();

    if (nodeA == _takyan || nodeB == _takyan) {
        auto otherNode = nodeA == _takyan ? nodeB : nodeA;

        if (otherNode == _kicker && !m_game->isOver())
        {
            auto takyanBody = _takyan->getPhysicsBody();
            Vec2 v = takyanBody->getVelocity();
            float limitY = takyanBody->getMass() * 1.0f;
            if (v.y < limitY) {
                v.y = MAX(limitY, v.y * 2.5f);
            }
            float limitX = takyanBody->getMass() * 1.0f;
            if (v.x < -limitX || v.x > limitX) {
                v.x = limitX * (v.x < 0 ? -1 : 1);
            }

            if (m_scoreCanAcquire == 3)
            {
                Vec2 zero;
                float distance = zero.distance(v);
                v.x = 0;
                v.y = distance;
            }

            takyanBody->setVelocity(v);
        }
        else if (otherNode == _floorBounds && m_game->isPracticeMode())
        {
            m_game->setScore(0);

            auto takyanBody = _takyan->getPhysicsBody();
            Vec2 velocity;

            velocity.y = takyanBody->getMass() * 2.50f;
            takyanBody->setVelocity(velocity);
        }
    }
}
Пример #22
0
bool Game2::onContactBegin(cocos2d::PhysicsContact& contact) {
	// Do something
	auto spriteA = (Sprite*)contact.getShapeA()->getBody()->getNode();
	auto spriteB = (Sprite*)contact.getShapeB()->getBody()->getNode();
	if ((spriteA->getName().compare("trampa") == 0 || spriteA->getName().compare("character") == 0) && (spriteB->getName().compare("trampa") == 0 || spriteB->getName().compare("character") == 0)) {
		if(muerto==false){
			_chara->vidas -= 1;
			muerto = true;
			def->setIntegerForKey("vidas", _chara->vidas);
			if (!def->getIntegerForKey("vidas") == 0) Restart();
			else {
				GotoMenuScene();
			}
		}
	}
	
	if ((spriteA->getName().compare("esfera") == 0 || spriteA->getName().compare("character") == 0) && (spriteB->getName().compare("esfera") == 0 || spriteB->getName().compare("character") == 0)) {
		GotoMenuScene();
	}
	return true;
}
void GameScene::Seperate(cocos2d::PhysicsContact &contact) // Created By An Unknown Source, Via Stack OverFlow
{
	auto a = contact.getShapeA()->getBody();
	auto b = contact.getShapeB()->getBody();
	float* v = (float*)contact.getData();

	if (a->getCollisionBitmask() == Ball_Bitmask)
	{
		auto va = a->getVelocity();
		va.normalize();
		a->setVelocity(va * v[0]);
	}

	if (b->getCollisionBitmask() == Ball_Bitmask)
	{
		auto vb = b->getVelocity();
		vb.normalize();
		b->setVelocity(vb * v[1]);
	}
	delete v;

}
Пример #24
0
bool RushPig::onContactBegin(cocos2d::PhysicsContact& contact)
{
	auto bodyA = contact.getShapeA()->getBody();
	auto bodyB = contact.getShapeB()->getBody();
	auto componentA = (BaseComponent*)bodyA->getNode();
	auto componentB = (BaseComponent*)bodyB->getNode();
	BaseComponent* enemyComponent;
	bool isComponentA = true;

	if (componentA->getType() == getType())
	{
		enemyComponent = componentB;
		isComponentA = true;
	}
	else
	{
		enemyComponent = componentA;
		isComponentA = false;
	}

	//미사일이랑 충돌 처리
	if (enemyComponent->getPhysicsBody()->getCategoryBitmask() == PHYC_MISSILE)
	{
		Missile* missile = static_cast<Missile*>(enemyComponent);

		float damage = missile->getDamage();

		m_Info.m_CurrentHp -= damage * 100 / (100 + m_Info.m_DefensivePower);

		cocos2d::log("HP : %d / %d", m_Info.m_CurrentHp, m_Info.m_MaxHp);
		//사망
		if (m_Info.m_CurrentHp <= 0)
		{
			m_IsDead = true;
		}
	}
	return true;
}
Пример #25
0
bool GameScene::onContactBegin(cocos2d::PhysicsContact & contact)
{
	PhysicsBody *a = contact.getShapeA()->getBody();
	PhysicsBody *b = contact.getShapeB()->getBody();
	if ((BALL_COLLISION_BITMASK == a->getCollisionBitmask() && (BRICK_COLLISION_BITMASK) == b->getCollisionBitmask()) ||
		(BALL_COLLISION_BITMASK == b->getCollisionBitmask() && (BRICK_COLLISION_BITMASK) == a->getCollisionBitmask()))
	{
		
		auto bricky = b->getNode();
		this->removeChild(bricky);

		score++;
		__String *tempScore = __String::createWithFormat( "%i", score );
        scoreLabel->setString( tempScore->getCString( ) );
		if (score == 50)
		{
			auto scene = GameOverScene::createScene(score);

			Director::getInstance()->replaceScene(TransitionFade::create(TRANSITION_TIME, scene));
		}
	}
	return true;
}
Пример #26
0
/** 碰撞开始事件
 *  @2015/01/19 14:14
 */
bool Level_8::onCollisionBegin(const cocos2d::PhysicsContact& contact)
{
    PhysicsBody* bodyA = contact.getShapeA()->getBody();
    PhysicsBody* bodyB = contact.getShapeB()->getBody();
    PhysicsBody* temp =nullptr;
    //log("A:%d B:%d",bodyA->getTag(),bodyB->getTag());
    if(bodyA->getTag() == 600050)
    {
        temp = bodyB;
        bodyB = bodyA;
        bodyA = temp;
    }
    if(bodyB->getTag() == 600050)
    {
        if (bodyA->getTag() == 400010) {
            log("火碰到冰块了  》》》》》》》》》》》》》");
            auto anim_iceo = CSLoader::createTimeline("Node/level_animation/l8_ice.csb");
            anim_iceo->gotoFrameAndPlay(0, 70, false);
            masklayer->removeFromParent();
            root_level->runAction(anim_iceo);
        }
    }
    return false;
}
Пример #27
0
bool WorldScene::onContactBegin(cocos2d::PhysicsContact &contact) {
	CCLOG("shape a cate : %d", contact.getShapeA()->getCategoryBitmask());
	CCLOG("shape b cate : %d", contact.getShapeB()->getCategoryBitmask());
	int bitA = contact.getShapeA()->getCategoryBitmask();
	int bitB = contact.getShapeB()->getCategoryBitmask();
	if (bitA == 3) {
		if (bitB == 1) {
			//Projectile hit enemy
			auto nodeB = contact.getShapeB()->getBody()->getNode();
			Projectile* pro = dynamic_cast<Projectile*>(contact.getShapeA()->getBody()->getNode());
			if (pro != NULL) {
				char mode = pro->getMode();
				int tag = nodeB->getTag();
				if (tag == 1) {
					Animal* node = dynamic_cast<Animal*>(nodeB);
					if (pro != NULL) {
						if (mode == 'b') {
							node->setHp(node->getHp() - 3);
						}
						else {
							node->setHp(node->getHp() - 1);
						}
					}
					CCLOG("%d", node->getHp());
					if (node->getHp() <= 0) {
						node->removeFromParent();
						setScore(getScore() + 100);
					}
				}
				else if (tag == 2) {
					Monster* node = dynamic_cast<Monster*>(nodeB);
					if (pro != NULL) {
						if (mode == 'b') {
							node->setHp(node->getHp() - 3);
						}
						else {
							node->setHp(node->getHp() - 1);
						}
					}
					CCLOG("%d", node->getHp());
					if (node->getHp() <= 0) {
						node->removeFromParent();
						setScore(getScore() + 500);
					}
				}




				if ((mode == 'a') || (tag == 3)) {
					if (pro != NULL)
						pro->removeFromParent();
				}
			}

			
		}
	}
	else if (bitA == 1) {
		if (bitB == 3) {
			//Enemy hit projectile
			auto nodeA = contact.getShapeA()->getBody()->getNode();
			Projectile* pro = dynamic_cast<Projectile*>(contact.getShapeB()->getBody()->getNode());
			if (pro != NULL) {
				char mode = pro->getMode();
				int tag = nodeA->getTag();
				if (tag == 1) {
					Animal* node = dynamic_cast<Animal*>(nodeA);
					if (pro != NULL) {
						if (mode == 'b') {
							node->setHp(node->getHp() - 3);
						}
						else {
							node->setHp(node->getHp() - 1);
						}
					}
					CCLOG("%d", node->getHp());
					if (node->getHp() <= 0) {
						node->removeFromParent();
						setScore(getScore() + 100);
					}
				}
				else if (tag == 2) {
					Monster* node = dynamic_cast<Monster*>(nodeA);
					if (pro != NULL) {
						if (mode == 'b') {
							node->setHp(node->getHp() - 3);
						}
						else {
							node->setHp(node->getHp() - 1);
						}
					}
					CCLOG("%d", node->getHp());
					if (node->getHp() <= 0) {
						node->removeFromParent();
						setScore(getScore() + 500);
					}
				}




				if ((mode == 'a') || (tag == 3)) {
					if (pro != NULL)
						pro->removeFromParent();
				}
			}
		}
		else if (bitB == 2) {
			//Enemy hit player
			Player* node = dynamic_cast<Player*>(contact.getShapeB()->getBody()->getNode());
			auto nodeA = contact.getShapeA()->getBody()->getNode();
			if ((Player::getJump() == 0) || (nodeA->getTag() == 2)) {
				if (node->getShell() == 0) {
					node->removeFromParentAndCleanup(true);
					death();
				}
				else {
					node->setShell(node->getShell() - 1);
					setShell(node->getShell());
				}
			}
			setScore(getScore() + 100);
			CCLOG("%d", Player::getJump());
		}
	}
	else if (bitA == 2) {
		if (bitB == 1) {
			//Player hit enemy
			Player* node = dynamic_cast<Player*>(contact.getShapeA()->getBody()->getNode());
			auto nodeB = contact.getShapeB()->getBody()->getNode();
			if ((Player::getJump() == 0) || (nodeB->getTag() == 2)) {
				if (node->getShell() == 0) {
					node->removeFromParentAndCleanup(true);
					death();
				}
				else {
					node->setShell(node->getShell() - 1);
					setShell(node->getShell());
				}
			}
			setScore(getScore() + 100);
			CCLOG("%d", Player::getJump());
		}
		else if (bitB == 4) {
			//Player hit quiver
			Player* node = dynamic_cast<Player*>(contact.getShapeA()->getBody()->getNode());
			auto nodeB = contact.getShapeB()->getBody()->getNode();
			if (nodeB->getTag() == 1) {
				node->setArrow(node->getArrow() + 20);
				contact.getShapeB()->getBody()->getNode()->removeFromParent();
				setArrow(node->getArrow());
				CCLOG("Arrow %d", node->getArrow());
			}
			else {
				node->setShell(node->getShell() + 1);
				contact.getShapeB()->getBody()->getNode()->removeFromParent();
				setShell(node->getShell());
			}
		}
	}
	else if (bitA == 4) {
		if (bitB == 2) {
			//Quiver hit Player
			Player* node = dynamic_cast<Player*>(contact.getShapeB()->getBody()->getNode());
			auto nodeA = contact.getShapeA()->getBody()->getNode();
			if (nodeA->getTag() == 1) {
				node->setArrow(node->getArrow() + 20);
				contact.getShapeA()->getBody()->getNode()->removeFromParent();
				setArrow(node->getArrow());
				CCLOG("Arrow %d", node->getArrow());
			}
			else {
				node->setShell(node->getShell() + 1);
				contact.getShapeA()->getBody()->getNode()->removeFromParent();
				setShell(node->getShell());
			}
		}
	}
	return true;
}
bool GameScene::setHit(cocos2d::PhysicsContact &contact)
{

	if (GameManager::sharedGameManager()->isGameLive == true)
	{

		PhysicsBody *a = contact.getShapeA()->getBody();
		PhysicsBody *b = contact.getShapeB()->getBody();

		float* v = new float[2];
		v[0] = a->getVelocity().length(); // Created By An Unknown Source, Via Stack OverFlow
		v[1] = b->getVelocity().length(); // Created By An Unknown Source, Via Stack OverFlow

		contact.setData(v);


		if ((1 == a->getCollisionBitmask() && 2 == b->getCollisionBitmask()) || (2 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask()))// BACK TO FRONT FOR NOW
		{
			bool hit = true;
		}

		else
		{
			bool hit = false;
		}

		if (hit = true)
		{

			if ((a->getCollisionBitmask() == Paddle_Bitmask && b->getCollisionBitmask() == Ball_Bitmask) || (a->getCollisionBitmask() == Ball_Bitmask && b->getCollisionBitmask() == Paddle_Bitmask))
			{
				Ball::sharedBall()->AddToDampening(5000.0f);
				SoundManager::sharedSoundManager()->PlaySoundEffect("ballRebound.mp3", false, 1.0f, 1.0f, 1.0f);
			}

			if ((a->getCollisionBitmask() == Brick_Bitmask && b->getCollisionBitmask() == Ball_Bitmask) || (a->getCollisionBitmask() == Ball_Bitmask && b->getCollisionBitmask() == Brick_Bitmask))
			{
				Ball::sharedBall()->AddToDampening(5000.0f);
				GameManager::sharedGameManager()->AddToScore(1);
				this->removeChild(contact.getShapeB()->getBody()->getNode());

				Ball::sharedBall()->AddToAcceleration(5000);
				//ScoreLabel->setString(StringUtils::format("%d", GameManager::sharedGameManager()->GetScore()));

				Vec2 first = contact.getShapeA()->getBody()->getNode()->convertToWorldSpace(Vec2(50, 50));

				x = first.x;
				y = first.y;

				this->schedule(schedule_selector(GameScene::SetPowerUp));

				//level = 50;
				if (level == 1)
				{
					number = number + 1;
					CCLOG("number = %i", number);

					brick.SetLevel(level);
					//if (number == 5)
					//{
					// CCLOG("level 2");
					// //level = 2;
					// this->removeChild(contact.getShapeA()->getBody()->getNode());
					//this->schedule(schedule_selector(GameScene::SetBrick));
					//this->schedule(schedule_selector(GameScene::SetBall));
					//}
				}

				else if (level == 2)
				{
					number = number + 1;
					brick.SetLevel(level);
					/*if (number == 5)
					{
					level = 3;
					this->removeChild(contact.getShapeA()->getBody()->getNode());
					this->schedule(schedule_selector(GameScene::SetBrick));
					this->schedule(schedule_selector(GameScene::SetBall));
					}*/

				}

				else if (level == 3)
				{
					number = number + 1;
					brick.SetLevel(level);
					/*if (number == 5)
					{
					level = 4;
					this->removeChild(contact.getShapeA()->getBody()->getNode());
					this->schedule(schedule_selector(GameScene::SetBrick));
					this->schedule(schedule_selector(GameScene::SetBall));
					}*/
				}

				else if (level == 4)
				{
					number = number + 1;
					brick.SetLevel(level);
					/*if (number == 5)
					{
					level = 5;
					this->removeChild(contact.getShapeA()->getBody()->getNode());
					this->schedule(schedule_selector(GameScene::SetBrick));
					this->schedule(schedule_selector(GameScene::SetBall));
					}*/
				}
				else if (level == 5)
				{
					number = number + 1;
					brick.SetLevel(level);
				}
			}
			//LIFE
			if ((a->getCollisionBitmask() == Paddle_Bitmask && b->getCollisionBitmask() == LiveUp_Bitmask) || (a->getCollisionBitmask() == LiveUp_Bitmask && b->getCollisionBitmask() == Paddle_Bitmask))
			{
				GameManager::sharedGameManager()->AddToLives(1);

				this->removeChild(contact.getShapeA()->getBody()->getNode());


			}
			//TWO
			if ((a->getCollisionBitmask() == Paddle_Bitmask && b->getCollisionBitmask() == TwoSplit_Bitmask) || (a->getCollisionBitmask() == TwoSplit_Bitmask && b->getCollisionBitmask() == Paddle_Bitmask))
			{

				this->removeChild(contact.getShapeA()->getBody()->getNode());

				Vec2 BallPos = contact.getShapeB()->getBody()->getNode()->convertToWorldSpace(Vec2(50, 50));
				xb = BallPos.x;
				yb = BallPos.y;

				balls = balls + 2;
				ba = ba + 2;

				CCLOG("Balls pu:%i", balls);
				this->schedule(schedule_selector(GameScene::SetBall));
			}
			//THREE
			if ((a->getCollisionBitmask() == Paddle_Bitmask && b->getCollisionBitmask() == ThreeSplit_Bitmask) || (a->getCollisionBitmask() == ThreeSplit_Bitmask && b->getCollisionBitmask() == Paddle_Bitmask))
			{
				this->removeChild(contact.getShapeA()->getBody()->getNode());

				Vec2 BallPos = contact.getShapeB()->getBody()->getNode()->convertToWorldSpace(Vec2(50, 50));
				xb = BallPos.x;
				yb = BallPos.y;

				balls = balls + 3;
				ba = ba + 3;
				this->schedule(schedule_selector(GameScene::SetBall));

			}
			//FOUR
			if ((a->getCollisionBitmask() == Paddle_Bitmask && b->getCollisionBitmask() == NineSplit_Bitmask) || (a->getCollisionBitmask() == NineSplit_Bitmask && b->getCollisionBitmask() == Paddle_Bitmask))
			{
				this->removeChild(contact.getShapeA()->getBody()->getNode());

				Vec2 BallPos = contact.getShapeB()->getBody()->getNode()->convertToWorldSpace(Vec2(50, 50));
				xb = BallPos.x;
				yb = BallPos.y;

				balls = balls + 8;
				ba = ba + 8;
				this->schedule(schedule_selector(GameScene::SetBall));
			}

			if ((a->getCollisionBitmask() == Death_Bitmask && b->getCollisionBitmask() == Ball_Bitmask) || (a->getCollisionBitmask() == Ball_Bitmask && b->getCollisionBitmask() == Death_Bitmask))
			{
				
				CCLOG("Balls enter:%i", balls);
				this->lives = GameManager::sharedGameManager()->GetLives();
				if (balls <= 1 && lives > 0)
				{
					GameManager::sharedGameManager()->AddToLives(-1);
					this->schedule(schedule_selector(GameScene::SetBall));
					balls = balls + 1;
					ba = ba + 1;

				}

				else if (balls <= 1 && lives <= 0)
				{
					GameManager::sharedGameManager()->AddToLives(-1);
				}

				if (balls > 1 && lives > 0)
				{
					
					balls = balls - 1;
					CCLOG("Balls return:%i", balls);
				}

				if (lives <= 0)
				{
					/*auto scene = HelloWorld::createScene();
					Director::getInstance()->replaceScene(TransitionFade::create(Transition_Length, scene));*/

					this->GameOver();
				}
				this->removeChild(contact.getShapeA()->getBody()->getNode());

			}

			if ((a->getCollisionBitmask() == Death_Bitmask && b->getCollisionBitmask() == LiveUp_Bitmask) || (a->getCollisionBitmask() == LiveUp_Bitmask && b->getCollisionBitmask() == Death_Bitmask))
			{
				this->removeChild(contact.getShapeA()->getBody()->getNode());
			}

			if ((a->getCollisionBitmask() == Death_Bitmask && b->getCollisionBitmask() == TwoSplit_Bitmask) || (a->getCollisionBitmask() == TwoSplit_Bitmask && b->getCollisionBitmask() == Death_Bitmask))
			{
				this->removeChild(contact.getShapeA()->getBody()->getNode());

			}

			if ((a->getCollisionBitmask() == Death_Bitmask && b->getCollisionBitmask() == ThreeSplit_Bitmask) || (a->getCollisionBitmask() == ThreeSplit_Bitmask && b->getCollisionBitmask() == Death_Bitmask))
			{
				this->removeChild(contact.getShapeA()->getBody()->getNode());
			}

			if ((a->getCollisionBitmask() == Death_Bitmask && b->getCollisionBitmask() == NineSplit_Bitmask) || (a->getCollisionBitmask() == NineSplit_Bitmask && b->getCollisionBitmask() == Death_Bitmask))
			{
				this->removeChild(contact.getShapeA()->getBody()->getNode());
			}
		}
	}
	return true;
}
Пример #29
0
void LevelThree::onContactPostSolve(cocos2d::PhysicsContact &contact, const cocos2d::PhysicsContactPostSolve& solve)
{
	PhysicsBody* a = contact.getShapeA()->getBody();
	PhysicsBody* b = contact.getShapeB()->getBody();

	if (1 == a->getCollisionBitmask() && 21 == b->getCollisionBitmask())
	{
		this->removeAllChildren();
		LevelThree::GoToLevel4();
		slingshot = true;
	}
	else if (21 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
	{
		this->removeAllChildren();
		LevelThree::GoToLevel4();
		slingshot = true;
	}
	else
	{
		if (1 == a->getCollisionBitmask() && 9 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		else if (9 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		if (1 == a->getCollisionBitmask() && 10 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		else if (10 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		if (1 == a->getCollisionBitmask() && 11 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		else if (11 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		if (1 == a->getCollisionBitmask() && 12 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		else if (12 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		if (1 == a->getCollisionBitmask() && 13 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		else if (13 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		if (1 == a->getCollisionBitmask() && 14 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		else if (14 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		if (1 == a->getCollisionBitmask() && 15 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		else if (15 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		if (1 == a->getCollisionBitmask() && 16 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		else if (16 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		if (1 == a->getCollisionBitmask() && 17 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		else if (17 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		if (1 == a->getCollisionBitmask() && 18 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		else if (18 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			LevelThree::GoToGameOverScene();
			slingshot = false;
		}
		if (1 == a->getCollisionBitmask() && 2 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		else if (2 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		if (1 == a->getCollisionBitmask() && 3 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		else if (3 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		if (1 == a->getCollisionBitmask() && 4 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		else if (4 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		if (1 == a->getCollisionBitmask() && 6 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		else if (6 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		if (1 == a->getCollisionBitmask() && 7 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		else if (7 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		if (1 == a->getCollisionBitmask() && 8 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
		else if (8 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask())
		{
			player->getPhysicsBody()->setVelocity(Vec2(0.0f, 0.0f));
			slingshot = true;
		}
	}
}
Пример #30
0
bool MonsterRush::onContactBegin(cocos2d::PhysicsContact& contact)
{
	auto bodyA = contact.getShapeA()->getBody();
	auto bodyB = contact.getShapeB()->getBody();
	auto componentA = (BaseComponent*)bodyA->getNode();
	auto componentB = (BaseComponent*)bodyB->getNode();
	BaseComponent* enemyComponent;
	bool isComponentA = true;

	if (componentA->getType() == getType())
	{
		enemyComponent = componentB;
		isComponentA = true;
	}
	else
	{
		enemyComponent = componentA;
		isComponentA = false;
	}

	//미사일이랑 충돌 처리
	if (enemyComponent->getPhysicsBody()->getCategoryBitmask() == PHYC_MISSILE)
	{
		Missile* missile = static_cast<Missile*>(enemyComponent);

		//수류탄은 뎀 안 입음
		if (missile->getType() == OT_MISSILE_GRENADE)
		{
			return false;
		}

		//몹이 쏜 건 안 맞음.
		if (!missile->isPlayerMissile())
		{
			return false;
		}

		float damage = missile->getDamage();

		m_Info.m_CurrentHp -= damage * 100 / (100 + m_Info.m_DefensivePower);

		//미사일에 의한 상태 이상 처리

		if (missile->getState() == Missile::MST_KNOCKBACK)
		{
			GET_SOUND_MANAGER()->createSound(SoundManager::PIG, false);
			m_KnockbackStartTime = GET_GAME_MANAGER()->getMicroSecondTime();
			if (missile->getAttackDir() == DIR_LEFT)
			{
				CommonState::enterKnockback(this, DIR_LEFT);
			}
			else
			{
				CommonState::enterKnockback(this, DIR_RIGHT);
			}

			setState(0,STAT_KNOCKBACK);
		}
		else if (missile->getState() == Missile::MST_BIND)
		{
			m_KnockbackStartTime = GET_GAME_MANAGER()->getMicroSecondTime();
			getPhysicsBody()->setVelocity(cocos2d::Vect(0, 0));
			setState(0,STAT_KNOCKBACK);
		}

		//사망
		if (m_Info.m_CurrentHp <= 0)
		{
			m_IsDead = true;
		}
	}

	//플레이어랑 부딪친 경우 이펙트 생성
	if (enemyComponent->getType() == OT_PLAYER)
	{
		GET_EFFECT_MANAGER()->createEffect(ET_PUNCH_MISSILE, enemyComponent->getPosition())->enter();
	}
	return true;
}