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


C++ PhysicsContact::getShapeA方法代码示例

本文整理汇总了C++中PhysicsContact::getShapeA方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsContact::getShapeA方法的具体用法?C++ PhysicsContact::getShapeA怎么用?C++ PhysicsContact::getShapeA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhysicsContact的用法示例。


在下文中一共展示了PhysicsContact::getShapeA方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onContactBegin

bool MonsterD::onContactBegin(PhysicsContact &contact) {
	switch (contact.getShapeA()->getBody()->getContactTestBitmask() |
		contact.getShapeB()->getBody()->getContactTestBitmask())
	{
	case ARROW_BIT_MASK | MONSTER1_BIT_MASK://箭射中怪物
	{
		//this->removeFromParentAndCleanup(true);
		auto a = contact.getShapeA()->getBody()->getNode();
		auto b = contact.getShapeB()->getBody()->getNode();
		log("dispear!!!!!!!!!!!!!!!");
		if (a != NULL) {
			if (UserDefault::getInstance()->getBoolForKey(SOUND_KEY)) {
				SimpleAudioEngine::getInstance()->playEffect(sound_4);
			}
			a->removeFromParentAndCleanup(true);

		}
		if (b != NULL) {
			if (UserDefault::getInstance()->getBoolForKey(SOUND_KEY)) {
				SimpleAudioEngine::getInstance()->playEffect(sound_4);
			}
			b->removeFromParentAndCleanup(true);
			//long bt = b->getTag();// tilemap->removeChildByTag();
			//b->removeFromParentAndCleanup(true);
			//log("bt %d", bt);
			//if (-1 < bt < 10001)tilemap->getLayer("pengzhuang")->removeChildByTag(bt);
		}
	}
	break;
	default:
		break;
	}
	return true;
}
开发者ID:MulticsYin,项目名称:Archer-cocos2d-x,代码行数:34,代码来源:monsterD.cpp

示例2: HandleCollision

bool GameplayLayer::HandleCollision(const PhysicsContact& contact)
{
    if(!player->isAlive || player->isInvulnerable)
        return false;
    
    if(contact.getShapeA()->getTag() == 3 || contact.getShapeB()->getTag() == 3)
    {
        if(!player->jumpAnimation->isDone())
        {
            player->IncreaseScore();
            playerScoreLabel->setString(String::createWithFormat("%d", (int)player->score)->getCString());
            CCLOG("JUMP");
            return false;
        }
    }
    else if(contact.getShapeA()->getTag() == 4 || contact.getShapeB()->getTag() == 4)
    {
        if(!player->duckAnimation->isDone())
        {
            player->IncreaseScore();
            playerScoreLabel->setString(String::createWithFormat("%d", (int)player->score)->getCString());
            CCLOG("DUCK");
            return false;
        }
    }
    
    player->Knockback();
    std::cout << "Player Hit" << std::endl;
    return false;
}
开发者ID:TwistedSystem,项目名称:twistedSystem,代码行数:30,代码来源:GameplayLayer.cpp

示例3: remove

void Coins::remove(const PhysicsContact &contact, Layer *layer)
{
	if(COIN_BITMASK == contact.getShapeA()->getBody()->getCollisionBitmask())
	{
		contact.getShapeA()->getBody()->removeFromWorld();
		layer->removeChild(contact.getShapeA()->getBody()->getNode());
	}
	else
	{
		contact.getShapeB()->getBody()->removeFromWorld();
		layer->removeChild(contact.getShapeB()->getBody()->getNode());
	}
}
开发者ID:4an70m,项目名称:FallingBlocks,代码行数:13,代码来源:Coins.cpp

示例4: success

bool GameScene24::onContactBegin(PhysicsContact& contact) {

    auto nodeA = (Sprite*)contact.getShapeA()->getBody()->getNode();

    auto nodeB = (Sprite*)contact.getShapeB()->getBody()->getNode();

    if (nodeA->getTag() == 13 && nodeB->getTag() == 14)
    {
        success();
    }
    if (nodeB->getTag() == 13 && nodeA->getTag() == 14)
    {
        success();
    }
    if (nodeB->getTag() == 14 && nodeA->getTag() != 14)
    {
        lose();
    }
    if (nodeA->getTag() == 14 && nodeB->getTag() != 14)
    {
        lose();
    }


    return true;
}
开发者ID:EMGAME,项目名称:Sister,代码行数:26,代码来源:GameScene24.cpp

示例5: onCollision

bool HelloWorld::onCollision(PhysicsContact& contact)
{
	CCLOG("Collision detected");
	auto playerShape = _sprPlayer->getPhysicsBody()->getFirstShape();
	if(playerShape != contact.getShapeA() && playerShape != contact.getShapeB())
	{
		return false;
	}
	
	if(_muteItem -> isVisible())
	{
		//CocosDenshion
		/*SimpleAudioEngine::getInstance()->stopBackgroundMusic();
		SimpleAudioEngine::getInstance()->playEffect("uh.wav");*/
	
		//New audio engine	
		AudioEngine::stopAll();	
		AudioEngine::play2d("uh.mp3");
	}

	UserDefault::getInstance()->setIntegerForKey("score",_score);
	_director->replaceScene(TransitionFlipX::create(1.0, GameOver::createScene()));
	auto body = _sprBomb -> getPhysicsBody();
	body->setVelocity(Vect());
	body->applyTorque(100900.5f);
	return false;
}
开发者ID:dungtrv,项目名称:SnackGame,代码行数:27,代码来源:HelloWorldScene.cpp

示例6: onContactBegin

bool Player::onContactBegin(PhysicsContact& contact)
{
	auto nodeA = contact.getShapeA()->getBody()->getNode();
	auto nodeB = contact.getShapeB()->getBody()->getNode();

	GameObject * other;

	if (dynamic_cast<Player*>(nodeA) == this)
	{
		other = dynamic_cast<GameObject*>(nodeB);
	}
	else if (dynamic_cast<Player*>(nodeB) == this)
	{
		other = dynamic_cast<GameObject*>(nodeA);
	}

	if (other->type == GameObjectType::DESTRUCTIBLE)
	{
		endGame();
		//end game screen
	}
	else
	{
		acceleration += 10;
	}

	return true;
}
开发者ID:JulianVolodia,项目名称:Win10Hacks,代码行数:28,代码来源:Player.cpp

示例7: onContactBegin

bool Coin::onContactBegin(PhysicsContact& contact)
{
	auto nodeA = contact.getShapeA()->getBody()->getNode();
	auto nodeB = contact.getShapeB()->getBody()->getNode();

	GameObject * other;

	if (dynamic_cast<Coin*>(nodeA) == this)
	{
		other = dynamic_cast<GameObject*>(nodeB);
	}
	else if (dynamic_cast<Coin*>(nodeB) == this)
	{
		other = dynamic_cast<GameObject*>(nodeA);
	}

	if (other->type == GameObjectType::DESTRUCTIBLE)
	{
	}
	else
	{
	}

	return true;
}
开发者ID:JulianVolodia,项目名称:Win10Hacks,代码行数:25,代码来源:Coin.cpp

示例8: onContactBegan

bool CognitoWorld::onContactBegan(PhysicsContact &contact)
{
    if(lvlConfigData.at("SetImmortal").asBool())
        return false;
    
    auto node = contact.getShapeA();
    int nodeBitMask = node->getCategoryBitmask();
    
    if(nodeBitMask == PhysicsCategory::Obstacle)
    {
        stopGame(false);
        return true;
    }
    
    node = contact.getShapeB();
    nodeBitMask = node->getCategoryBitmask();
    
    if(nodeBitMask == PhysicsCategory::Obstacle)
    {
        stopGame(false);
        return true;
    }
    
    return false;
}
开发者ID:supratimr,项目名称:GameAssignment02,代码行数:25,代码来源:CognitoWorldScene.cpp

示例9: contactLogicPreSolve

bool YellowWall::contactLogicPreSolve(PhysicsContact& contact, PhysicsContactPreSolve& solve, ContactLogic *logic)
{
	PhysicsBody* body1 = contact.getShapeA()->getBody();
	PhysicsBody* body2 = contact.getShapeB()->getBody();
	if ((body1->getTag() == Type_Flag && body2->getTag() == Type_BoxSprite) ||
		(body1->getTag() == Type_BoxSprite && body2->getTag() == Type_Flag))
	{
		if (!this->m_bIsContactFlag)
		{
			this->m_bIsContactFlag = true;
			this->schedule(schedule_selector(YellowWall::updateState), 0.1f);

		}
		if (this->m_bIsWin)
		{
			logic->setWinState(true);
		}
		return false;
	}
	if (body1->getTag() == Type_Flag || body2->getTag() == Type_Flag)
	{
		return false;
	}
	return true;
}
开发者ID:franklen,项目名称:boxgohome,代码行数:25,代码来源:YellowWall.cpp

示例10: onContactSeparate

bool PassGateComponent::onContactSeparate(PhysicsContact& contact)
{
	if ((contact.getShapeA()->getCollisionBitmask() == PLAYER_ID) && (contact.getShapeB()->getCollisionBitmask() == PASSGATE_AREA_ID))
	{
		if ((_collisionPointX != 0) && (abs(_collisionPointX - contact.getShapeA()->getBody()->getPosition().x) > GATE_WIDTH-5))
		{
			// change 'Y' coordinate of the 'gate' main point
			auto action = MoveTo::create(GATE_ACTION_SPEED, Point(_visibleSize.width / 2, nextPosY()));
			_mainNode->runAction(action);
		}

		_collisionPointX = contact.getShapeA()->getBody()->getPosition().x;
	}

	return false;
}
开发者ID:kira333,项目名称:MyProjects,代码行数:16,代码来源:PassGateComponent.cpp

示例11: onContactBegin

bool GameLayer::onContactBegin(PhysicsContact& contact) {
	auto b_1 = (Sprite*)contact.getShapeA()->getBody()->getNode();
    auto b_2 = (Sprite*)contact.getShapeB()->getBody()->getNode();
	if (b_1 == ball && b_1->getTag() == 100)
	{
		log("FromBall");
		BallisTouch = true;
	}
	else if(b_2 == ball && b_2->getTag() == 100)
	{
		log("FromBall");
				BallisTouch = true;

	}else if (b_1->getPhysicsBody()->getCategoryBitmask()==ColliderTypeBall && b_1->getTag() != 100)
	{
		 auto randomColor = rand()%4;
    showStarParticleEffect(randomColor, bird->getPosition(), this);
	}
	else if(b_2->getPhysicsBody()->getCategoryBitmask()==ColliderTypeBall && b_2->getTag() != 100)
	{
		 auto randomColor = rand()%4;
    showStarParticleEffect(randomColor, bird->getPosition(), this);
	}
	else
	{
			this->gameOver();
			unschedule(schedule_selector(GameLayer::addBallObstacle));

	}
	return true;
}
开发者ID:HotWordland,项目名称:Earlybird,代码行数:31,代码来源:GameLayer.cpp

示例12: contactLogicSeperate

void BrokableWall::contactLogicSeperate( PhysicsContact &contact, ContactLogic *logic )
{
	PhysicsBody* body1 = contact.getShapeA()->getBody();
	PhysicsBody* body2 = contact.getShapeB()->getBody();
	if (body1 != nullptr && body2 != nullptr)
	{
		if (body1->getTag() == Type_BoxSprite || body2->getTag() == Type_BoxSprite)
		{
			Vec2 velocity = body1->getVelocity() + body2->getVelocity();
			if (m_bIsCanContact && velocity.getLengthSq() > 10 * 10)
			{
				m_durability--;
				if (m_durability <= 0)
				{
					this->removeFromParent();
				}
				else
				{
					m_bIsCanContact = false;
					this->schedule(schedule_selector(BrokableWall::updateContactState), 0.1f);
				}
			}
		}
	}
}
开发者ID:liujian890508,项目名称:boxgohome,代码行数:25,代码来源:BrokableWall.cpp

示例13: onContactBegin

bool SoaringLayer::onContactBegin(PhysicsContact& contact)
{
    Node* nodes[2];
    nodes[0] = contact.getShapeA()->getBody()->getNode();
    nodes[1] = contact.getShapeB()->getBody()->getNode();
    
    if (nodes[0] && nodes[1])
    {
        for (int i = 0; i < 2; i++)
        {
            int j = (i + 1) % 2;
            
            if (nodes[i]->getTag() == FLYPLANT_TAG)
            {
                FlyPlant *flyPlant = dynamic_cast<FlyPlant*>(nodes[i]);
                if (flyPlant)
                {
                    flyPlant->onContactBegin(nodes[j]);
                }
            }
            if (nodes[i]->getTag() == OBSTACLE_TAG)
            {
                Obstacle *obstacle = dynamic_cast<Obstacle*>(nodes[i]);
                if (obstacle)
                {
                    obstacle->onContactBegin(nodes[j]);
                }
            }
        }
    }
    
    return false;
}
开发者ID:WalterShih,项目名称:GameJamClass,代码行数:33,代码来源:SoaringLayer.cpp

示例14:

bool Level_2Scene::onContactBegan(PhysicsContact &contact)
{
	auto nodeEnemy = contact.getShapeA()->getBody()->getNode();//could be enemy or visa veras 
	auto nodeProjectile = contact.getShapeB()->getBody()->getNode();//could be projectile or visa versa 


	nodeEnemy->removeFromParent();//remove the enemy 
	CCLOG("removed");
	SimpleAudioEngine::getInstance()->playEffect(DEATH_SOUND_SFX);//enemy dying sound
	nodeProjectile->removeFromParent();//remove the projectile 
	CCLOG("point added");
	score++;


	__String * tempScore = __String::createWithFormat("%i", score);
	scoreLabel->setString(tempScore->getCString());
	//if score reaches 10 new level or end game scene with transmitions to gameOverscene or new scene 

	if (score == 1)
	{
		auto scene = Level_3_Scene::createScene();
		Director::getInstance()->replaceScene(TransitionFade::create(TRANSATION_TIME, scene));
	}

	return true;
}
开发者ID:cosmicowl21,项目名称:The-gits-game-folder,代码行数:26,代码来源:Level_2Scene.cpp

示例15: onContactBegin

bool GameController::onContactBegin(PhysicsContact & contact)
{
   if( contact.getShapeA()->getBody()->getNode()->getTag() == contact.getShapeB()->getBody()->getNode()->getTag())
   {
       log("onContactBegin");
       if(arrow->getPhysicsBody())
       {
           arrow->getPhysicsBody()->setVelocity(Vec2(0, 0));
           board_body->setVelocity(Vec2::ZERO);
           
       }
       //upper_body_layer->removeChild(arrow);
       
       //transitioning from tip to no-tip arrow
       arrow->setVisible(false);
       noTipArrow->setVisible(true);
       
       //angle
       float angle = arrow->getPhysicsBody()->getRotation();
       noTipArrow->setRotation(angle);
       
       //position
       Vec2 point = contact.getContactData()->points[0];
       label->setString(std::to_string(point.y));
       noTipArrow->setPosition(Vec2(noTipArrow->getPosition().x, point.y - (board_layer->getPosition().y)));
       
       return true;
       
   }
    
    return true;
}
开发者ID:badarmaqsood,项目名称:archer,代码行数:32,代码来源:GameController.cpp


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