コード例 #1
0
void StickOnCollision::handleEvent(const CollisionEvent& e)
 {

	GameObject obj = e.getOtherObject();
	if (obj.getType() == GameObject::Type::TILE)
	{
		hookPoint = obj.getPos();
		PhysicsComponent * hookPhysics = owner_.getComponent<PhysicsComponent>();
		hookPhysics->setVelX(0);
		hookPhysics->setVelY(0);
		
		auto tileCollider = e.getOtherCollider();
		auto hookCollider = owner_.getComponent<ColliderComponent>();

		float hookBot = hookCollider->getBottom();
		float tileBot = tileCollider.getBottom();
		float tileTop = tileCollider.getTop();

		if (hookBot == tileTop)
		{
			isConnected = false;
		}
		else
		{
			isConnected = true;
		}
		//LOG("INFO") << "Hook is connected at " << hookPoint;
		
	}
}
コード例 #2
0
void FallingAIComponent::handleEvent(const CollisionEvent & e)
{

	if (e.getOtherObject().getType() == GameObject::Type::TILE)
	{
		//colliders
		auto blockCollider = owner_.getComponent<ColliderComponent>();
		ColliderComponent& tileCollider = e.getOtherCollider();

		if (blockCollider->getBottom() == tileCollider.getTop())
		{
			state_ = STATE::RISING;
			LOG("HARVEY") << "RISING";
		}
		else if(state_ != STATE::NEUTRAL)
		{
			state_ = STATE::DELAY;
			LOG("HARVEY") << "DELAY";
		}


	}
}