本文整理汇总了C#中TouchCollection.AnyTouch方法的典型用法代码示例。如果您正苦于以下问题:C# TouchCollection.AnyTouch方法的具体用法?C# TouchCollection.AnyTouch怎么用?C# TouchCollection.AnyTouch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TouchCollection
的用法示例。
在下文中一共展示了TouchCollection.AnyTouch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleInput
private void HandleInput()
{
// get all of our input states
keyboardState = Keyboard.GetState();
gamePadState = GamePad.GetState(PlayerIndex.One);
touchState = TouchPanel.GetState();
accelerometerState = Accelerometer.GetState();
// Exit the game when back is pressed.
if (gamePadState.Buttons.Back == ButtonState.Pressed)
{ } //Exit();
bool continuePressed =
keyboardState.IsKeyDown(Keys.Space) ||
gamePadState.IsButtonDown(Buttons.A) ||
touchState.AnyTouch();
// Perform the appropriate action to advance the game and
// to get the player back to playing.
if (!wasContinuePressed && continuePressed)
{
if (!level.Player.IsAlive)
{
level.StartNewLife();
}
else if (level.TimeRemaining == TimeSpan.Zero)
{
if (!level.ReachedExit)
ReloadCurrentLevel();
// LoadNextLevel();
//else
}
}
wasContinuePressed = continuePressed;
}
示例2: GetInput
/// <summary>
/// Gets player horizontal movement and jump commands from input.
/// </summary>
private void GetInput(
KeyboardState keyboardState,
GamePadState gamePadState,
TouchCollection touchState,
AccelerometerState accelState,
DisplayOrientation orientation)
{
// Get analog horizontal movement.
movement = gamePadState.ThumbSticks.Left.X * MoveStickScale;
// Ignore small movements to prevent running in place.
if (Math.Abs(movement) < 0.5f)
movement = 0.0f;
// Move the player with accelerometer
if (Math.Abs(accelState.Acceleration.Y) > 0.10f)
{
// set our movement speed
movement = MathHelper.Clamp(-accelState.Acceleration.Y * AccelerometerScale, -1f, 1f);
// if we're in the LandscapeLeft orientation, we must reverse our movement
if (orientation == DisplayOrientation.LandscapeRight)
movement = -movement;
}
// If any digital horizontal movement input is found, override the analog movement.
if (gamePadState.IsButtonDown(Buttons.DPadLeft) ||
keyboardState.IsKeyDown(Keys.Left) ||
keyboardState.IsKeyDown(Keys.A))
{
movement = -1.0f;
}
else if (gamePadState.IsButtonDown(Buttons.DPadRight) ||
keyboardState.IsKeyDown(Keys.Right) ||
keyboardState.IsKeyDown(Keys.D))
{
movement = 1.0f;
}
// Check if the player wants to jump.
isJumping =
gamePadState.IsButtonDown(JumpButton) ||
keyboardState.IsKeyDown(Keys.Space) ||
keyboardState.IsKeyDown(Keys.Up) ||
keyboardState.IsKeyDown(Keys.W) ||
touchState.AnyTouch();
}
示例3: GetInput
/// <summary>
/// Gets player horizontal movement and jump commands from input.
/// </summary>
private void GetInput(
KeyboardState keyboardState,
GamePadState gamePadState,
TouchCollection touchState,
AccelerometerState accelState,
DisplayOrientation orientation)
{
// Get analog horizontal movement.
movement = gamePadState.ThumbSticks.Left.X * MoveStickScale;
// Ignore small movements to prevent running in place.
if (Math.Abs(movement) < 0.5f)
movement = 0.0f;
// Move the player with accelerometer
if (Math.Abs(accelState.Acceleration.Y) > 0.10f)
{
// set our movement speed
movement = MathHelper.Clamp(-accelState.Acceleration.Y * AccelerometerScale, -1f, 1f);
// if we're in the LandscapeLeft orientation, we must reverse our movement
if (orientation == DisplayOrientation.LandscapeRight)
movement = -movement;
}
// If any digital horizontal movement input is found, override the analog movement.
if (keyboardState.IsKeyDown(Keys.Left) ||
keyboardState.IsKeyDown(Keys.A))
{
movement = -1.0f;
}
else if (keyboardState.IsKeyDown(Keys.Right) ||
keyboardState.IsKeyDown(Keys.D))
{
movement = 1.0f;
}
// Weapon switching
if (gamePadState.IsButtonDown(Buttons.DPadLeft))
{
weapon.Reset();
weapon = m_handgun;
}
else if (gamePadState.IsButtonDown(Buttons.DPadUp))
{
weapon.Reset();
weapon = m_shotgun;
}
else if (gamePadState.IsButtonDown(Buttons.DPadRight))
{
weapon.Reset();
weapon = m_knife;
}
if (gamePadState.IsButtonDown(SwitchButton) && !old_gamePadState.IsButtonDown(SwitchButton))
{
weapon.Reset();
if (weapon == m_handgun)
weapon = m_shotgun;
else if (weapon == m_shotgun)
weapon = m_knife;
else
weapon = m_handgun;
}
// Check if the player wants to jump.
isJumping =
gamePadState.IsButtonDown(JumpButton) ||
keyboardState.IsKeyDown(Keys.Space) ||
keyboardState.IsKeyDown(Keys.Up) ||
keyboardState.IsKeyDown(Keys.W) ||
touchState.AnyTouch();
if (gamePadState.IsButtonDown(RollButton) && !old_gamePadState.IsButtonDown(RollButton))
{
if (canRollAgain && isOnGround)
{
isRolling = true;
canRollAgain = false;
}
}
isThrowGrenade = false;
if (!isRolling)
{
// release the charged bomb
if (old_gamePadState.IsButtonDown(GrenadeButton) && !gamePadState.IsButtonDown(GrenadeButton))
{
m_bomb.Shoot();
}
// charge up the bomb throw if button held
if (gamePadState.IsButtonDown(GrenadeButton) && isOnGround && m_bomb.CanAttack)
{
isThrowGrenade = true;
m_bomb.Charging(this.position);
}
// other attacks
//.........这里部分代码省略.........
示例4: HandleInput
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;
// get all of our input states
keyboardState = Keyboard.GetState();
gamePadState_1 = GamePad.GetState(PlayerIndex.One);
gamePadState_2 = GamePad.GetState(PlayerIndex.Two);
gamePadStates[0] = gamePadState_1;
gamePadStates[1] = gamePadState_2;
touchState = TouchPanel.GetState();
accelerometerState = Accelerometer.GetState();
// Exit the game when back is pressed.
//if (gamePadState_1.Buttons.Back == ButtonState.Pressed)
// Exit();
if (input.IsPauseGame(null))
{
ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
}
else
{
foreach (Player player in PlatformerGame.Players)
{
bool continuePressed =
keyboardState.IsKeyDown(Keys.Space) ||
gamePadStates[PlatformerGame.Players.IndexOf(player)].IsButtonDown(Buttons.A) ||
touchState.AnyTouch();
if (!player.IsAlive)
{
level.StartNewLife(player);
}
if (level.ReachedExit)
{
LoadNextLevel();
}
}
//check if both player is in the "no-man lands"
if (players[0].Position.X == -999.9f && players[1].Position.X == -999.9f)
{
//players[attacker_id].Reset(Vector2.Zero);
level.StartNewLife(players[attacker_id]);
}
}
}
示例5: HandleInput
private void HandleInput()
{
// get all of our input states
keyboardState = Keyboard.GetState();
gamePadState = GamePad.GetState(PlayerIndex.One);
touchState = TouchPanel.GetState();
accelerometerState = Accelerometer.GetState();
// Exit the game when back is pressed.
if (gamePadState.Buttons.Back == ButtonState.Pressed ||
keyboardState.IsKeyDown(Keys.Escape))
{
Exit();
}
bool continuePressed =
keyboardState.IsKeyDown(Keys.Space) ||
gamePadState.IsButtonDown(Buttons.A) ||
touchState.AnyTouch();
wasContinuePressed = continuePressed;
}
示例6: HandleInput
private void HandleInput(GameTime gameTime)
{
// get all of our input states
previousKeyboardState = keyboardState;
keyboardState = Keyboard.GetState();
touchState = TouchPanel.GetState();
gamePadState = virtualGamePad.GetState(touchState, GamePad.GetState(PlayerIndex.One));
accelerometerState = Accelerometer.GetState();
MouseState mouseState = Mouse.GetState();
Vector2 playerPos = Vector2.Transform(level.Player.Position, globalTransformation);
Vector2 lookDir = Vector2.Normalize(mouseState.Position.ToVector2() - playerPos);
spotlight.Rotation = (float) Math.Atan2(lookDir.Y, lookDir.X);
#if !NETFX_CORE
// Exit the game when back is pressed.
if (gamePadState.Buttons.Back == ButtonState.Pressed)
Exit();
#endif
if (keyboardState.IsKeyDown(ConsoleToggleOpenKey) && !previousKeyboardState.IsKeyDown(ConsoleToggleOpenKey))
Console.ToggleOpenClose();
var continuePressed = false;
if (!Console.IsAcceptingInput)
{
penumbraController.InputEnabled = true;
continuePressed =
keyboardState.IsKeyDown(Keys.Space) ||
gamePadState.IsButtonDown(Buttons.A) ||
touchState.AnyTouch();
// Perform the appropriate action to advance the game and
// to get the player back to playing.
if (!wasContinuePressed && continuePressed)
{
if (!level.Player.IsAlive)
{
level.StartNewLife();
}
else if (level.TimeRemaining == TimeSpan.Zero)
{
if (level.ReachedExit)
LoadNextLevel();
else
ReloadCurrentLevel();
}
}
}
else
{
penumbraController.InputEnabled = false;
}
wasContinuePressed = continuePressed;
virtualGamePad.Update(gameTime);
}
示例7: ReadInput
/// <summary>
/// Handles input for horizontal movement and jumps.
/// </summary>
public void ReadInput(
KeyboardState keyboardState,
GamePadState gamePadState,
TouchCollection touchState,
AccelerometerState accelState,
DisplayOrientation orientation)
{
//360 Controller movements
movement = gamePadState.ThumbSticks.Left.X * MoveStickScale;
#if WINDOWS_PHONE
if (PhoneMainMenuScreen.GameOptions.controlOptions != 2)
movement = VirtualThumbsticks.LeftThumbstick.X * MoveStickScale;
#endif
//Stops animating in place for analog controls
if (Math.Abs(movement) < 0.5f)
movement = 0.0f;
#if WINDOWS_PHONE
if (PhoneMainMenuScreen.GameOptions.controlOptions != 1)
{
// Move the player with accelerometer
if (Math.Abs(accelState.Acceleration.Y) > 0.10f)
{
// set our movement speed
movement = MathHelper.Clamp(-accelState.Acceleration.Y * AccelerometerScale, -1f, 1f);
// if we're in the LandscapeLeft orientation, we must reverse our movement
if (orientation == DisplayOrientation.LandscapeRight)
movement = -movement;
}
}
#endif
//Keyboard movements (overwrites analog stick)
if (keyboardState.IsKeyDown(Keys.A) || gamePadState.IsButtonDown(Buttons.DPadLeft))
movement = -1.0f;
else if (keyboardState.IsKeyDown(Keys.D) || gamePadState.IsButtonDown(Buttons.DPadRight))
movement = 1.0f;
//checks for jumps
jumping = gamePadState.IsButtonDown(Buttons.A) ||
keyboardState.IsKeyDown(Keys.Space) ||
keyboardState.IsKeyDown(Keys.Down);
#if WINDOWS_PHONE
if (PhoneMainMenuScreen.GameOptions.controlOptions == 2)
{
jumping = touchState.AnyTouch();
}
if (PhoneMainMenuScreen.GameOptions.controlOptions != 2)
{
if (VirtualThumbsticks.RightThumbstickCenter != null)
{
jumping = true;
}
}
#endif
}