本文整理汇总了C#中InputHelper.IsNewButtonPress方法的典型用法代码示例。如果您正苦于以下问题:C# InputHelper.IsNewButtonPress方法的具体用法?C# InputHelper.IsNewButtonPress怎么用?C# InputHelper.IsNewButtonPress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputHelper
的用法示例。
在下文中一共展示了InputHelper.IsNewButtonPress方法的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: Mouse
private void Mouse(InputHelper state)
{
Vector2 position = Camera2D.ConvertScreenToWorld(state.MousePosition);
if (state.IsOldButtonPress(MouseButtons.LeftButton))
{
MouseUp();
}
else if (state.IsNewButtonPress(MouseButtons.LeftButton))
{
MouseDown(position);
}
if (_fixedMouseJoint != null)
{
_fixedMouseJoint.WorldAnchorB = position;
}
}
示例3: 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 );
}
示例4: 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);
}
示例5: HandleCursor
private void HandleCursor(InputHelper input)
{
Vector2 position = Camera.ConvertScreenToWorld(input.Cursor);
if ((input.IsNewButtonPress(Buttons.A) ||
input.IsNewMouseButtonPress(MouseButtons.LeftButton)) &&
_fixedMouseJoint == null)
{
Fixture savedFixture = World.TestPoint(position);
if (savedFixture != null)
{
Body body = savedFixture.Body;
_fixedMouseJoint = new FixedMouseJoint(body, position);
_fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
World.AddJoint(_fixedMouseJoint);
body.Awake = true;
}
}
if ((input.IsNewButtonRelease(Buttons.A) ||
input.IsNewMouseButtonRelease(MouseButtons.LeftButton)) &&
_fixedMouseJoint != null)
{
World.RemoveJoint(_fixedMouseJoint);
_fixedMouseJoint = null;
}
if (_fixedMouseJoint != null)
{
_fixedMouseJoint.WorldAnchorB = position;
}
}
示例6: Mouse
//private void Touch(InputHelper state)
//{
// ////////////////////////
// //Current touch position
// ////////////////////////
// if (state.CurrentTouchPosition != prevtouchlocation && state.CurrentTouchPoint != null)
// {
// Vector2 p = Camera2D.ConvertScreenToWorld(new Vector2(state.CurrentTouchPoint.X, state.CurrentTouchPoint.Y));
// prevtouchlocation = p;
// if (DebugView != null && p != Vector2.Zero)
// {
// if (joint1 != null)
// {
// if (state.NumberOfSurfaceTouches > 0)
// {
// if (hookpointmanager.IsNearAHookPoint(p))
// {
// if (swinger.Body.JointList != null && CanRemoveJoint)
// {
// //////////////
// //Remove Joint
// //////////////
// RemoveJoint();
// ///////////
// //Add Joint
// ///////////
// CreateJoint(p);
// }
// else if (swinger.Body.JointList == null)
// {
// ///////////
// //Add Joint
// ///////////
// CreateJoint(p);
// //TimeoutTimer.Stop();
// }
// }
// }
// ///////////////////////////
// //Remove after many touches
// ///////////////////////////
// else if (swinger.Body.JointList != null && CanRemoveJoint)
// {
// //////////////
// //Remove Joint
// //////////////
// //RemoveJoint();
// }
// }
// }
// }
//}
private void Mouse(InputHelper state)
{
Vector2 position = Camera.ConvertScreenToWorld(new Vector2(state.Cursor.X, state.Cursor.Y));
if (hookpointmanager.IsNearAHookPoint(position) &&
state.MouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
{
MouseDown(position);
}
/////////////////////////////////
//TODO Convert all
/////////////////////////////////
Vector2 measurestring = Camera.ConvertScreenToWorld(pausefont.MeasureString("Pause"));
//Pause Button Press
float x = PauseText.X +3;
float y = PauseText.Y +1.3f;
if (position.X >= x - 4 && position.X <= x + 4 &&
position.Y >= y - 1 && position.Y <= y + 1)
//if ((int)PauseText.X == (int)position.X && (int)PauseText.Y == (int)position.Y)
{
iHUD.IsEnabled(false);
ScreenManager.AddScreen(new PauseScreen("PAUSE",""));
}
//Back Button Press
if (state.IsNewButtonPress(Buttons.Back))
{
iHUD.IsEnabled(false);
ScreenManager.AddScreen(new PauseScreen("PAUSE", ""));
}
}