本文整理汇总了C++中MovingObject::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ MovingObject::GetPosition方法的具体用法?C++ MovingObject::GetPosition怎么用?C++ MovingObject::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MovingObject
的用法示例。
在下文中一共展示了MovingObject::GetPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleCollisionsWithMapEdges
void CollisionHandler::HandleCollisionsWithMapEdges(MovingObject& _obj)
{
if (_obj.GetPosition().x < 0)
{
_obj.UpdateAfterCollisionWithMapEdge(CollisionDirection::LEFT, _obj.GetPosition().x);
}
float gapRightEdge = _obj.GetPosition().x - (m_levelSize.x - _obj.GetCoordinates().width);
if (gapRightEdge > 0)
{
_obj.UpdateAfterCollisionWithMapEdge(CollisionDirection::RIGHT, gapRightEdge);
}
if (_obj.GetPosition().y > m_levelSize.y)
_obj.Kill();
}
示例2: onEvent
void NewCharacterReadListener::onEvent(const std::string &_eventType, Event* _event)
{
MovingObject *character = _event->GetMovingObject();
if (character->GetName() == "Mario")
m_gameEngine->SetMarioInitialPosition(character->GetPosition());
m_gameEngine->AddCharacterToArray(character);
m_gameEngine->AddForegroundItemToArray(character);
}
示例3: UpdateCharacterPosition
void GameEngine::UpdateCharacterPosition(MovingObject& _character, float _dt)
{
unsigned int id = _character.GetID();
_character.UpdatePosition(_dt);
sf::Vector2f pos = _character.GetPosition();
m_listForegroundItems[id]->SetX(pos.x);
m_listForegroundItems[id]->SetY(pos.y);
}
示例4: ShootArrow
void NPC::ShootArrow()
{
if (!m_flags[eAttacking])
{
//TODO: this isn't properly cleaned up.
MovingObject* arrow = new MovingObject(m_graphicContext, *m_resourceManager, m_position.x, m_position.y, "Arrow");
arrow->ConnectSlots(*m_drawSignal, *m_updateSignal);
arrow->SetEnvList(m_environment);
double launchAngle = Utility::CalculateTrajectory(arrow->GetPosition(), m_target->GetPosition(), arrow->GetSpeed(eCompositeSpeed), true);
arrow->SetSpeed(eXSpeed, arrow->GetSpeed(eCompositeSpeed) * sin(launchAngle));
arrow->SetSpeed(eYSpeed, arrow->GetSpeed(eCompositeSpeed) * cos(launchAngle));
StartAttack();
arrow->StartMoving(m_direction);
}
}