本文整理汇总了C++中Vector2::Direction方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2::Direction方法的具体用法?C++ Vector2::Direction怎么用?C++ Vector2::Direction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2
的用法示例。
在下文中一共展示了Vector2::Direction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeLookDisc
Vector2 Controller::MakeLookDisc(const Mathematics::Vector2 p_ScreenCentre) const
{
Vector2 ret = m_States.MouseAndKeyboard().Position - p_ScreenCentre;
ret = (ret.LengthSquared() > deadDist * deadDist) ? ret : Zero2();
//ret += m_States.Gamepad().RightStick;
return ret.IsAtOrigin() ? Zero2() : ret.Direction();
}
示例2: MakeMoveDisc
Vector2 Controller::MakeMoveDisc() const
{
Vector2 ret = Zero2();
ret(0) = MakeAxisFromKeys(KeyboardKey::A, KeyboardKey::D);
ret(1) = MakeAxisFromKeys(KeyboardKey::S, KeyboardKey::W);
ret += m_States.Gamepad().LeftStick;
return ret.IsAtOrigin() ? Zero2() : ret.Direction();
}
示例3: Update
void InputState::Update()
{
Reset();
m_System->Update();
//buttons
if (m_System->IsKeyDown(Keys::SPACE) || m_System->IsGamePadButtonDown(Xbox::A))
{
m_ActionPressed = true;
}
if (m_System->IsKeyDown(Keys::ENTER) || m_System->IsGamePadButtonDown(Xbox::X))
{
m_ConfirmPressed = true;
}
if (m_System->IsKeyDown(Keys::ESCAPE) || m_System->IsGamePadButtonDown(Xbox::Y))
{
m_DenyPressed = true;
}
if(m_System->IsKeyDown(Keys::F1))
{
m_FullscreenPressed = true;
}
//axes or discs
Vector2 leftRaw;
Vector2 rightRaw;
if (m_System->GamepadIsConnected())
{
leftRaw(1) = -m_System->GetLeftAnalogX();
leftRaw(2) = m_System->GetLeftAnalogY();
rightRaw(1) = m_System->GetRightAnalogX();
rightRaw(2) = m_System->GetRightAnalogY();
m_LeftDisc = leftRaw - m_LeftDiscCentre;
m_RightDisc = rightRaw - m_LeftDiscCentre;
}
else
{
if (m_System->IsKeyDown(Keys::A))
{
leftRaw += U();
}
if (m_System->IsKeyDown(Keys::D))
{
leftRaw += -U();
}
if (m_System->IsKeyDown(Keys::W))
{
leftRaw += V();
}
if (m_System->IsKeyDown(Keys::S))
{
leftRaw += -V();
}
if (m_System->IsKeyDown(Keys::LEFT))
{
rightRaw += -U();
}
if (m_System->IsKeyDown(Keys::RIGHT))
{
rightRaw += U();
}
if (m_System->IsKeyDown(Keys::UP))
{
rightRaw += V();
}
if (m_System->IsKeyDown(Keys::DOWN))
{
rightRaw += -V();
}
if (!EquivalentToZero(leftRaw.LengthSquared()))
{
m_LeftDisc = leftRaw.Direction();
}
if (!EquivalentToZero(rightRaw.LengthSquared()))
{
m_RightDisc = rightRaw.Direction();
}
}
}