本文整理汇总了C#中InputHelper.IsNewKeyPress方法的典型用法代码示例。如果您正苦于以下问题:C# InputHelper.IsNewKeyPress方法的具体用法?C# InputHelper.IsNewKeyPress怎么用?C# InputHelper.IsNewKeyPress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputHelper
的用法示例。
在下文中一共展示了InputHelper.IsNewKeyPress方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleInput
public override void HandleInput(InputHelper input)
{
//Xbox
if (input.IsNewButtonPress(Buttons.Start))
{
EnableOrDisableFlag(DebugViewFlags.Shape);
EnableOrDisableFlag(DebugViewFlags.DebugPanel);
EnableOrDisableFlag(DebugViewFlags.PerformanceGraph);
}
if (input.IsNewButtonPress(Buttons.Back))
{
ExitScreen();
}
//Windows
if (input.IsNewKeyPress(Keys.F1))
{
EnableOrDisableFlag(DebugViewFlags.Shape);
}
else if (input.IsNewKeyPress(Keys.F2))
{
EnableOrDisableFlag(DebugViewFlags.DebugPanel);
}
else if (input.IsNewKeyPress(Keys.F3))
{
EnableOrDisableFlag(DebugViewFlags.PerformanceGraph);
}
else if (input.IsNewKeyPress(Keys.F4))
{
EnableOrDisableFlag(DebugViewFlags.AABB);
}
else if (input.IsNewKeyPress(Keys.F5))
{
EnableOrDisableFlag(DebugViewFlags.CenterOfMass);
}
else if (input.IsNewKeyPress(Keys.F6))
{
EnableOrDisableFlag(DebugViewFlags.Joint);
}
else if (input.IsNewKeyPress(Keys.F7))
{
EnableOrDisableFlag(DebugViewFlags.ContactPoints);
EnableOrDisableFlag(DebugViewFlags.ContactNormals);
}
else if (input.IsNewKeyPress(Keys.F8))
{
EnableOrDisableFlag(DebugViewFlags.PolygonPoints);
}
if (input.IsNewKeyPress(Keys.Escape))
{
ExitScreen();
}
if (World != null)
{
#if XBOX
GamePad(input.CurrentGamePadState, input.LastGamePadState);
#else
Mouse(input);
#endif
}
base.HandleInput(input);
}
示例2: HandleInput
public override void HandleInput( InputHelper input, GameTime gameTime )
{
if ( input.VirtualState.ThumbSticks.Left.X > 0.5f || input.GamePadState.IsButtonDown( Buttons.RightTrigger ) ) {
_acceleration = Math.Min( _acceleration + (float)( 2.0 * gameTime.ElapsedGameTime.TotalSeconds ), 1f );
} else if ( input.VirtualState.ThumbSticks.Left.X < -0.5f || input.GamePadState.IsButtonDown( Buttons.LeftTrigger ) ) {
_acceleration = Math.Max( _acceleration - (float)( 2.0 * gameTime.ElapsedGameTime.TotalSeconds ), -1f );
} else if ( input.VirtualState.Buttons.A == ButtonState.Pressed ) {
_acceleration = 0f;
} else if ( input.IsNewKeyPress(Keys.R) || input.IsNewButtonPress(Buttons.X )) {
_car.Rotation = 0;
_car.Position += ConvertUnits.ToSimUnits( 0, -100 );
} else {
_acceleration -= Math.Sign( _acceleration ) * (float)( 2.0 * gameTime.ElapsedGameTime.TotalSeconds );
}
base.HandleInput( input, gameTime );
}
示例3: HandleInput
public override void HandleInput(InputHelper input, GameTime gameTime)
{
// Control debug view
if (input.IsNewButtonPress(Buttons.Start))
{
EnableOrDisableFlag(DebugViewFlags.Shape);
EnableOrDisableFlag(DebugViewFlags.DebugPanel);
EnableOrDisableFlag(DebugViewFlags.PerformanceGraph);
EnableOrDisableFlag(DebugViewFlags.Joint);
EnableOrDisableFlag(DebugViewFlags.ContactPoints);
EnableOrDisableFlag(DebugViewFlags.ContactNormals);
EnableOrDisableFlag(DebugViewFlags.Controllers);
}
if (input.IsNewKeyPress(Keys.F1))
{
EnableOrDisableFlag(DebugViewFlags.Shape);
}
if (input.IsNewKeyPress(Keys.F2))
{
EnableOrDisableFlag(DebugViewFlags.DebugPanel);
EnableOrDisableFlag(DebugViewFlags.PerformanceGraph);
}
if (input.IsNewKeyPress(Keys.F3))
{
EnableOrDisableFlag(DebugViewFlags.Joint);
}
if (input.IsNewKeyPress(Keys.F4))
{
EnableOrDisableFlag(DebugViewFlags.ContactPoints);
EnableOrDisableFlag(DebugViewFlags.ContactNormals);
}
if (input.IsNewKeyPress(Keys.F5))
{
EnableOrDisableFlag(DebugViewFlags.PolygonPoints);
}
if (input.IsNewKeyPress(Keys.F6))
{
EnableOrDisableFlag(DebugViewFlags.Controllers);
}
if (input.IsNewKeyPress(Keys.F7))
{
EnableOrDisableFlag(DebugViewFlags.CenterOfMass);
}
if (input.IsNewKeyPress(Keys.F8))
{
EnableOrDisableFlag(DebugViewFlags.AABB);
}
if (input.IsNewButtonPress(Buttons.Back) || input.IsNewKeyPress(Keys.Escape))
{
ExitScreen();
}
if (HasCursor)
{
HandleCursor(input);
}
if (_userAgent != null)
{
HandleUserAgent(input);
}
if (EnableCameraControl)
{
HandleCamera(input, gameTime);
}
base.HandleInput(input, gameTime);
}
示例4: HandleCamera
private void HandleCamera(InputHelper input, GameTime gameTime)
{
Vector2 camMove = Vector2.Zero;
if (input.KeyboardState.IsKeyDown(Keys.Up))
{
camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
if (input.KeyboardState.IsKeyDown(Keys.Down))
{
camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
if (input.KeyboardState.IsKeyDown(Keys.Left))
{
camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
if (input.KeyboardState.IsKeyDown(Keys.Right))
{
camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
if (input.KeyboardState.IsKeyDown(Keys.PageUp))
{
Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
}
if (input.KeyboardState.IsKeyDown(Keys.PageDown))
{
Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
}
if (camMove != Vector2.Zero)
{
Camera.MoveCamera(camMove);
}
if (input.IsNewKeyPress(Keys.Home))
{
Camera.ResetCamera();
}
}
示例5: HandleCursor
private void HandleCursor(InputHelper nInput)
{
Vector2 position = mCamera.ConvertScreenToWorld(nInput.Cursor);
if ((nInput.IsNewKeyPress(Keys.A) ||
nInput.IsNewMouseButtonPress(MouseButtons.LeftButton)) &&
_fixedMouseJoint == null)
{
Fixture savedFixture = mWorld.TestPoint(position);
if (savedFixture != null)
{
Body body = savedFixture.Body;
_fixedMouseJoint = new FixedMouseJoint(body, position);
_fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
mWorld.AddJoint(_fixedMouseJoint);
body.Awake = true;
}
}
if ((nInput.IsNewKeyRelease(Keys.A) ||
nInput.IsNewMouseButtonRelease(MouseButtons.LeftButton)) &&
_fixedMouseJoint != null)
{
mWorld.RemoveJoint(_fixedMouseJoint);
_fixedMouseJoint = null;
}
if (_fixedMouseJoint != null)
{
_fixedMouseJoint.WorldAnchorB = position;
}
}
示例6: HandleInput
public override void HandleInput(InputHelper nInput, GameTime nGameTime)
{
// Control debug views
if (nInput.IsNewKeyPress(Keys.F1))
{
EnableOrDisableFlag(DebugViewFlags.Shape);
}
if (nInput.IsNewKeyPress(Keys.F2))
{
EnableOrDisableFlag(DebugViewFlags.DebugPanel);
EnableOrDisableFlag(DebugViewFlags.PerformanceGraph);
}
if (nInput.IsNewKeyPress(Keys.F3))
{
EnableOrDisableFlag(DebugViewFlags.Joint);
}
if (nInput.IsNewKeyPress(Keys.F4))
{
EnableOrDisableFlag(DebugViewFlags.ContactPoints);
EnableOrDisableFlag(DebugViewFlags.ContactNormals);
}
if (nInput.IsNewKeyPress(Keys.F5))
{
EnableOrDisableFlag(DebugViewFlags.PolygonPoints);
}
if (nInput.IsNewKeyPress(Keys.F6))
{
EnableOrDisableFlag(DebugViewFlags.Controllers);
}
if (nInput.IsNewKeyPress(Keys.F7))
{
EnableOrDisableFlag(DebugViewFlags.CenterOfMass);
}
if (nInput.IsNewKeyPress(Keys.F8))
{
EnableOrDisableFlag(DebugViewFlags.AABB);
}
if (nInput.IsNewKeyPress(Keys.Back) || nInput.IsNewKeyPress(Keys.Escape))
{
ExitScreen();
}
if (HasCursor)
{
HandleCursor(nInput);
}
//Pass nInput on to player
mPlayer.HandleInput(nInput);
}