/// <summary> /// Handle the player's input. /// </summary> /// <param name="gameTime"> /// The game Time. /// </param> /// <param name="input"> /// gamepad input state /// </param> public override void HandleInput(GameTime gameTime, InputState input) { if (IsActive) { if (input == null) { throw new ArgumentNullException("input"); } VirtualThumbsticks.Update(input); if (input.IsPauseGame(null)) { pauseCurrentGame(); } } if (input.TouchState.Count > 0) { foreach (TouchLocation touch in input.TouchState) { lastTouchPosition = touch.Position; } } isSmokebuttonClicked = false; PlayerIndex player; // If there was any touch if (VirtualThumbsticks.RightThumbstickCenter.HasValue) { // Button BodyRectangle Rectangle buttonRectangle = new Rectangle((int)smokeButtonPosition.X, (int)smokeButtonPosition.Y, smokeButton.Width / 2, smokeButton.Height); // Touch BodyRectangle Rectangle touchRectangle = new Rectangle((int)VirtualThumbsticks.RightThumbstickCenter.Value.X, (int)VirtualThumbsticks.RightThumbstickCenter.Value.Y, 1, 1); // If the touch is in the button if (buttonRectangle.Contains(touchRectangle)) { isSmokebuttonClicked = true; } } if (input.IsKeyDown(Keys.Space, ControllingPlayer, out player)) { isSmokebuttonClicked = true; } if (input.Gestures.Count > 0) { if (isLevelEnd) { if (input.Gestures[0].GestureType == GestureType.Tap) { userTapToExit = true; } } } }
/// <summary> /// Handles user input as a part of screen logic update. /// </summary> /// <param name="gameTime">Game time information.</param> /// <param name="input">Input information.</param> public override void HandleInput(GameTime gameTime, InputState input) { if (input == null) { throw new ArgumentNullException("input"); } if (input.IsPauseGame(null)) { Exit(); } // Return to the main menu when a tep gesture is recognized if (input.Gestures.Count > 0) { GestureSample sample = input.Gestures[0]; if (sample.GestureType == GestureType.Tap) { Exit(); input.Gestures.Clear(); } } }
/// <summary> /// Handle the player's input. /// </summary> /// <param name="gameTime"> /// The game Time. /// </param> /// <param name="input"> /// gamepad input state /// </param> public override void HandleInput(GameTime gameTime, InputState input) { if (IsActive) { if (input == null) { throw new ArgumentNullException("input"); } this.input = input; VirtualThumbsticks.Update(input); if (input.IsPauseGame(null)) { pauseCurrentGame(); } } if (input.TouchState.Count > 0) { foreach (TouchLocation touch in input.TouchState) { lastTouchPosition = touch.Position; } } if (input.Gestures.Count > 0) { if (isLevelEnd) { if (input.Gestures[0].GestureType == GestureType.Tap) { userTapToExit = true; } } } }