本文整理汇总了C++中Input::GetKey方法的典型用法代码示例。如果您正苦于以下问题:C++ Input::GetKey方法的具体用法?C++ Input::GetKey怎么用?C++ Input::GetKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::GetKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessInput
void MazeMovement::ProcessInput(const Input& input, float delta)
{
if (!m_moving)
{
SetFrontTile();
if (input.GetKeyUp(Input::KEY_LEFT))
{
GetTransform()->Rotate(PxQuat(ToRadians(-90.0f), PxVec3(0, 1, 0)));
SetFrontTile();
}
if (input.GetKeyUp(Input::KEY_RIGHT))
{
GetTransform()->Rotate(PxQuat(ToRadians(90.0f), PxVec3(0, 1, 0)));
SetFrontTile();
}
if (input.GetKey(Input::KEY_UP))
{
switch (m_frontTile)
{
case 2:
m_ogPosition = *GetTransform()->GetPos();
m_desiredPosition = *GetTransform()->GetPos() + PxVec3(-GetTransform()->GetRot()->getBasisVector0().z, 0.0f, GetTransform()->GetRot()->getBasisVector0().x);
m_gridPosition = PxVec2(m_gridPosition.x - (int)GetTransform()->GetRot()->getBasisVector0().z, m_gridPosition.y + (int)GetTransform()->GetRot()->getBasisVector0().x);
SetFrontTile();
m_moving = true;
break;
}
}
if (input.GetKey(Input::KEY_DOWN))
{
switch (m_maze[(int)m_gridPosition.x + (int)GetTransform()->GetRot()->getBasisVector0().z][(int)m_gridPosition.y - (int)GetTransform()->GetRot()->getBasisVector0().x])
{
case 2:
m_ogPosition = *GetTransform()->GetPos();
m_desiredPosition = (*GetTransform()->GetPos() - PxVec3(-GetTransform()->GetRot()->getBasisVector0().z, 0.0f, +GetTransform()->GetRot()->getBasisVector0().x));
m_gridPosition = PxVec2(m_gridPosition.x + (int)GetTransform()->GetRot()->getBasisVector0().z, m_gridPosition.y - (int)GetTransform()->GetRot()->getBasisVector0().x);
SetFrontTile();
m_moving = true;
break;
}
}
if (input.GetKeyUp(Input::KEY_F) && m_frontTile == 3)
{
m_parent->GetEngine().Stop();
}
}
}
示例2: ProcessInput
void FreeLook::ProcessInput(const Input& input, float delta)
{
if(input.GetKey(m_unlockMouseKey))
{
input.SetCursor(true);
m_mouseLocked = false;
}
if(m_mouseLocked)
{
Vector2f deltaPos = input.GetMousePosition() - m_windowCenter;
bool rotY = deltaPos.GetX() != 0;
bool rotX = deltaPos.GetY() != 0;
if(rotY)
{
GetTransform()->Rotate(Vector3f(0,1,0), ToRadians(deltaPos.GetX() * m_sensitivity));
}
if(rotX)
{
GetTransform()->Rotate(GetTransform()->GetRot()->GetRight(), ToRadians(deltaPos.GetY() * m_sensitivity));
}
if(rotY || rotX)
{
input.SetMousePosition(m_windowCenter);
}
}
if(input.GetMouseDown(Input::MOUSE_LEFT_BUTTON))
{
input.SetCursor(false);
input.SetMousePosition(m_windowCenter);
m_mouseLocked = true;
}
}