本文整理汇总了C#中InputState.WasKeyPressed方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.WasKeyPressed方法的具体用法?C# InputState.WasKeyPressed怎么用?C# InputState.WasKeyPressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState.WasKeyPressed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleInput
public override void HandleInput(InputState input)
{
#region Wenn Spieler Auswählt (Hier Leertaste)
if (input.WasKeyPressed(Microsoft.Xna.Framework.Input.Keys.Space, PlayerIndex.One))
{
klick = true;
}
else
{
klick = false;
}
#endregion
#region Wenn Spieler eine Waffe abgefeuert hat (Hier noch mit S realisiert)
if (input.WasKeyPressed(Microsoft.Xna.Framework.Input.Keys.S, PlayerIndex.One))
{
shoot=true;
}
else
{
shoot = false;
}
#endregion
#region Spiel Beenden (Esc)
if (input.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Escape, PlayerIndex.One))
{
Environment.Exit(0);
}
#endregion
base.HandleInput(input);
}
示例2: HandleInput
public void HandleInput(InputState input)
{
// -- Select Gizmo Mode -- //
if (input.WasKeyPressed(Keys.D1))
{
ActiveMode = GizmoMode.Translate;
}
else if (input.WasKeyPressed(Keys.D2))
{
ActiveMode = GizmoMode.Rotate;
}
else if (input.WasKeyPressed(Keys.D3))
{
ActiveMode = GizmoMode.NonUniformScale;
}
else if (input.WasKeyPressed(Keys.D4))
{
ActiveMode = GizmoMode.UniformScale;
}
// -- Cycle TransformationSpaces -- //
if (input.WasKeyPressed(Keys.Space))
{
if (ActiveSpace == TransformSpace.Local)
ActiveSpace = TransformSpace.World;
else
ActiveSpace = TransformSpace.Local;
}
// -- Cycle PivotTypes -- //
if (input.WasKeyPressed(Keys.P))
{
if (ActivePivot == PivotType.WorldOrigin)
ActivePivot = PivotType.ObjectCenter;
else
ActivePivot++;
}
// -- Toggle PrecisionMode -- //
if (input.IsKeyDown(Keys.LeftShift))
{
precisionMode = true;
}
else
precisionMode = false;
// -- Toggle Snapping -- //
if (input.WasKeyPressed(Keys.C))
{
SnapEnabled = !SnapEnabled;
}
if (input.Mouse.WasButtonPressed(Framework.MouseButtons.Left) && ActiveAxis == GizmoAxis.None)
{
// add to selection or clear current selection
if (input.IsKeyUp(addToSelection) && input.IsKeyUp(removeFromSelection) || input.IsKeyDown(Keys.LeftAlt))
{
Selection.Clear();
}
PickObject(input.Mouse.Position, input.IsKeyDown(removeFromSelection));
}
else if (input.WasKeyPressed(Keys.R))
{
Selection.Clear();
}
if (Enabled)
{
if (input.Mouse.WasButtonPressed(Framework.MouseButtons.Left))
{
// reset for intersection (plane vs. ray)
intersectPosition = Vector3.Zero;
// reset for snapping
translationScaleSnapDelta = Vector3.Zero;
rotationSnapDelta = 0;
}
lastIntersectionPosition = intersectPosition;
if (input.Mouse.WasButtonHeld(Framework.MouseButtons.Left) && ActiveAxis != GizmoAxis.None)
{
if (ActiveMode == GizmoMode.Translate || ActiveMode == GizmoMode.NonUniformScale || ActiveMode == GizmoMode.UniformScale)
{
#region Translate & Scale
Vector3 delta = Vector3.Zero;
Ray ray = Engine.ray;
Matrix transform = Matrix.Invert(rotationMatrix);
ray.Position = Vector3.Transform(ray.Position, transform);
ray.Direction = Vector3.TransformNormal(ray.Direction, transform);
if (ActiveAxis == GizmoAxis.X || ActiveAxis == GizmoAxis.XY)
{
Plane plane = new Plane(Vector3.Forward, Vector3.Transform(position,
Matrix.Invert(rotationMatrix)).Z);
float? intersection = ray.Intersects(plane);
if (intersection.HasValue)
{
intersectPosition = (ray.Position + (ray.Direction *
//.........这里部分代码省略.........