本文整理汇总了C#中InputState.IsNewButtonPress方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.IsNewButtonPress方法的具体用法?C# InputState.IsNewButtonPress怎么用?C# InputState.IsNewButtonPress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState.IsNewButtonPress方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleInput
public override void HandleInput(InputState input)
{
if (input.IsNewButtonPress(Buttons.Back)) Back();
if (input.IsNewButtonTick(Buttons.DPadLeft)) LeftClick();
if (input.IsNewButtonTick(Buttons.DPadRight)) RightClick();
if (input.IsNewButtonTick(Buttons.DPadUp)) UpClick();
if (input.IsNewButtonTick(Buttons.DPadDown)) DownClick();
if (input.IsNewButtonRelease(Buttons.A)) ClickItem();
}
示例2: HandleInput
public override void HandleInput(GameTime gameTime, InputState input)
{
// cancel the current screen if the user presses the back button
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.Back, null, out player))
{
ExitScreen();
}
RootControl.HandleInput(input);
base.HandleInput(gameTime, input);
}
示例3: HandleInput
public override void HandleInput(InputState input)
{
PlayerIndex pi;
if(input.TapPosition.HasValue || input.IsMenuCancel(null, out pi) || input.IsNewButtonPress(Buttons.Back, null, out pi))
ExitScreen();
base.HandleInput(input);
}
示例4: HandleInput
public override void HandleInput(GameTime gameTime, InputState input)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
{
ScreenManager.AddScreen(new GameplayPause("Pause!"), ControllingPlayer);
}
bool screenDone = false;
foreach (Tripa tripa in _tripas)
{
screenDone = tripa.Done;
if (!screenDone)
{
break;
}
}
if (screenDone)
{
IsCoverable = true;
ScreenManager.AddScreen(new GameplaySuccess("Success!"), ControllingPlayer);
return;
}
TouchCollection touchState = input.TouchState;
if (touchState.Count == 0)
{
return;
}
foreach (TouchLocation touch in touchState)
{
if (touch.Position.X > 100.0f && touch.Position.Y > 100.0f)
{
_touchId = touch.Id;
}
}
touchState.FindById(_touchId, out touchLocation);
if (touchLocation.State == TouchLocationState.Released)
{
_activeTripa = null;
_touchedTripa = false;
_touchId = 0;
_touchedPositions.Clear();
_actualTouchedPositions.Clear();
_vertices = _loneVertex;
_indices = _loneIndex;
return;
}
if (touchLocation.State == TouchLocationState.Pressed)
{
foreach (Tripa tripa in _tripas)
{
if (tripa.Area.Contains(new Vector3(touchLocation.Position, 0)) == ContainmentType.Contains)
{
if (tripa.Done)
{
break; // GAME OVER!!!
}
_activeTripa = tripa;
_touchedTripa = true;
_touchedPositions.Add(touchLocation.Position);
_actualTouchedPositions.Add(touchLocation.Position);
break;
}
}
}
if (touchLocation.State == TouchLocationState.Moved)
{
if (!_touchedPositions.Contains(touchLocation.Position) &&
_touchedTripa)
{
if (_activeTripa.Done)
{
return;
}
Vector2 point1 = _touchedPositions[_touchedPositions.Count - 1];
Vector2 point2 = touchLocation.Position;
Vector2 delta = point2 - point1;
float distance = delta.LengthSquared();
Vector2 direction = delta / distance;
Vector2 newPoint = new Vector2();
for (float i = 0.05f; i < 1.0f; i = i + 0.05f)
{
newPoint = point1 + direction * (distance * i);
//.........这里部分代码省略.........
示例5: HandleInput
/// <summary>
/// Input helper method provided by GameScreen. Packages up the various input
/// values for ease of use.
/// </summary>
/// <param name="input">The state of the gamepads</param>
public override void HandleInput(InputState input)
{
if (input.IsNewButtonPress(Buttons.Back)) Back();
if (Movable)
{
#region DPAD CONTROLS
if (input.IsNewButtonTick(Buttons.DPadUp))
{
if (faceSelected)
{
selected.row = Height - 1;
faceSelected = false;
}
else if (selected.row == 0) faceSelected = true;
else selected.row--;
}
if (input.IsNewButtonTick(Buttons.DPadDown))
{
if (faceSelected)
{
selected.row = 0;
faceSelected = false;
}
else if (selected.row < Height - 1) selected.row++;
else faceSelected = true;
}
if (input.IsNewButtonTick(Buttons.DPadLeft) && !faceSelected)
{
if (selected.col == 0) selected.col = Width - 1;
else selected.col--;
}
if (input.IsNewButtonTick(Buttons.DPadRight) && !faceSelected)
{
if (selected.col < Width - 1) selected.col++;
else selected.col = 0;
}
#endregion
if (!faceSelected)
if ((Game.options.FlagWithPlay && input.IsButtonPressed(Buttons.A)) ||
(!Game.options.FlagWithPlay && input.IsButtonPressed(Buttons.B)))
faceValue = Face.Scared;
if (faceValue == Face.Scared)
if ((Game.options.FlagWithPlay && !input.IsButtonPressed(Buttons.A)) ||
(!Game.options.FlagWithPlay && !input.IsButtonPressed(Buttons.B)))
faceValue = Face.Happy;
if (input.IsNewButtonRelease(Buttons.A))
{
if (faceSelected) SetGame(Height, Width, Mines);
else if (Game.options.FlagWithPlay) Click();
else TileFlag();
}
if (input.IsNewButtonRelease(Buttons.B) && !faceSelected)
{
if (Game.options.FlagWithPlay) TileFlag();
else Click();
}
}
else if (input.IsNewButtonRelease(Buttons.A)) SetGame(Height, Width, Mines);
}
示例6: HandleInput
/// <summary>
/// Responds to user input, changing the selected entry and accepting
/// or cancelling the menu.
/// </summary>
public override void HandleInput(GameTime gameTime, InputState input)
{
// we cancel the current menu screen if the user presses the back button
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
{
OnCancel(player);
}
// look for any taps that occurred and select any entries that were tapped
//int count = input.Gestures.Count;
//for (int i = 0; i < count; i++)
//{
// if (input.Gestures[i].GestureType == GestureType.Tap)
// {
// // convert the position to a Point that we can test against a Rectangle
// Point tapLocation = new Point((int)input.Gestures[i].Position.X, (int)input.Gestures[i].Position.Y);
// // iterate the entries to see if any were tapped
// for (int j = 0; j < menuEntries.Count; j++)
// {
// MenuEntry menuEntry = menuEntries[j];
// if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
// {
// // select the entry. since gestures are only available on Windows Phone,
// // we can safely pass PlayerIndex.One to all entries since there is only
// // one player on Windows Phone.
// OnSelectEntry(j, PlayerIndex.One);
// }
// }
// }
//}
foreach (GestureSample gesture in input.Gestures)
{
if (gesture.GestureType == GestureType.Tap)
{
// convert the position to a Point that we can test against a Rectangle
Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);
// iterate the entries to see if any were tapped
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
{
// select the entry. since gestures are only available on Windows Phone,
// we can safely pass PlayerIndex.One to all entries since there is only
// one player on Windows Phone.
OnSelectEntry(i, PlayerIndex.One);
}
}
}
}
}
示例7: HandleInput
/// <summary>
/// Responds to user input, changing the selected entry and accepting
/// or cancelling the menu.
/// </summary>
public override void HandleInput(InputState input)
{
// we cancel the current menu screen if the user presses the back button
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
{
OnCancel(player);
}
// look for any taps that occurred and select any entries that were tapped
foreach (GestureSample gesture in input.Gestures)
{
if (gesture.GestureType == GestureType.Tap)
{
// convert the position to a Point that we can test against a Rectangle
Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);
// iterate the entries to see if any were tapped
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
{
// select the entry. since gestures are only available on Windows Phone,
// we can safely pass PlayerIndex.One to all entries since there is only
// one player on Windows Phone.
OnSelectEntry(i, PlayerIndex.One);
}
}
}
}
if (input.IsMenuUp(ControllingPlayer))
{
selectedEntry--;
if (selectedEntry < 0)
selectedEntry = menuEntries.Count - 1;
}
// Move to the next menu entry?
if (input.IsMenuDown(ControllingPlayer))
{
selectedEntry++;
if (selectedEntry >= menuEntries.Count)
selectedEntry = 0;
}
// Accept or cancel the menu?
if (input.IsMenuSelect(ControllingPlayer,out player))
{
OnSelectEntry(selectedEntry,player);
}
else if (input.IsMenuCancel(ControllingPlayer,out player))
{
if (this.GetType() != typeof(MainMenuScreen))
{
this.ExitScreen();
}
else
{
this.ScreenManager.Game.Exit();
}
}
}
示例8: HandleInput
/// <summary>
/// Lets the game respond to player input. Unlike the Update method,
/// this will only be called when the gameplay screen is active.
/// </summary>
public override void HandleInput(InputState input)
{
if (input == null)
throw new ArgumentNullException("input");
// Look up inputs for the active player profile.
int playerIndex = (int)ControllingPlayer.Value;
KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];
// if the user pressed the back button, we return to the main menu
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
{
HighScoreScreen.SaveHighscore();
LoadingScreen.Load(ScreenManager, false, ControllingPlayer, new BackgroundScreen(), new MainMenuScreen());
}
else
{
// Otherwise move the player position.
Vector2 movement = Vector2.Zero;
if (keyboardState.IsKeyDown(Keys.Left))
movement.X--;
if (keyboardState.IsKeyDown(Keys.Right))
movement.X++;
if (keyboardState.IsKeyDown(Keys.Up))
movement.Y--;
if (keyboardState.IsKeyDown(Keys.Down))
movement.Y++;
Vector2 thumbstick = gamePadState.ThumbSticks.Left;
movement.X += thumbstick.X;
movement.Y -= thumbstick.Y;
if (movement.Length() > 1)
movement.Normalize();
playerPosition += movement * 2;
}
}
示例9: HandleInput
public override void HandleInput(GameTime gameTime, InputState input)
{
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.Back, null, out player))
{
ExitScreen();
//LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new MainMenuScreen());
}
RootControl.HandleInput(input);
}
示例10: HandleInput
/// <summary>
/// Responds to user input, changing the selected entry and accepting
/// or cancelling the menu.
/// </summary>
public override void HandleInput(InputState input)
{
// we cancel the current menu screen if the user presses the back button
PlayerIndex player;
if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
{
OnCancel(player);
}
// look for any taps that occurred and select any entries that were tapped
foreach (GestureSample gesture in input.Gestures)
{
if (gesture.GestureType == GestureType.Tap)
{
// convert the position to a Point that we can test against a Rectangle
Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);
// iterate the entries to see if any were tapped
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
{
// select the entry. since gestures are only available on Windows Phone,
// we can safely pass PlayerIndex.One to all entries since there is only
// one player on Windows Phone.
OnSelectEntry(i, PlayerIndex.One);
}
}
}
}
if (!ScreenManager.IsPhone)
{
Point mouseLocation = new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y);
for (int i = 0; i < menuEntries.Count; i++)
{
MenuEntry menuEntry = menuEntries[i];
if (GetMenuEntryHitBounds(menuEntry).Contains(mouseLocation))
{
selectedEntry = i;
// Mouse left click?
if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed)
{
// select the entry. since gestures are only available on Windows Phone,
// we can safely pass PlayerIndex.One to all entries since there is only
// one player on Windows Phone.
OnSelectEntry(i, PlayerIndex.One);
}
}
}
}
}