Example #1
0
        /// <summary>
        /// Evaluates the action against a given InputState.
        /// </summary>
        /// <param name="state">The InputState to test for the action.</param>
        /// <param name="controllingPlayer">The player to test, or null to allow any player.</param>
        /// <param name="player">If controllingPlayer is null, this is the player that performed the action.</param>
        /// <returns>True if the action occurred, false otherwise.</returns>
        public bool Evaluate(InputState state, PlayerIndex? controllingPlayer, out PlayerIndex player)
        {
            // Figure out which delegate methods to map from the state which takes care of our "newPressOnly" logic
            ButtonPress buttonTest;
            KeyPress keyTest;
            if (newPressOnly)
            {
                buttonTest = state.IsNewButtonPress;
                keyTest = state.IsNewKeyPress;
            }
            else
            {
                buttonTest = state.IsButtonPressed;
                keyTest = state.IsKeyPressed;
            }

            // Now we simply need to invoke the appropriate methods for each button and key in our collections
            foreach (Buttons button in buttons)
            {
                if (buttonTest(button, controllingPlayer, out player))
                    return true;
            }
            foreach (Keys key in keys)
            {
                if (keyTest(key, controllingPlayer, out player))
                    return true;
            }

            // If we got here, the action is not matched
            player = PlayerIndex.One;
            return false;
        }
Example #2
0
 public override void HandleInput(GameTime gameTime, InputState input)
 {
     foreach (GestureSample gesture in input.Gestures)
     {
         if (gesture.GestureType == GestureType.Tap)
         {
             if (Tapped != null) Tapped(this, null);
         }
     }
     base.HandleInput(gameTime, input);
 }
Example #3
0
 public override void HandleInput(GameTime gameTime, InputState input)
 {
     TouchCollection touchCollection = TouchPanel.GetState();
     foreach (TouchLocation tl in touchCollection)
     {
         if ((tl.State == TouchLocationState.Pressed)
                 || (tl.State == TouchLocationState.Moved))
         {
             _gameModel.TargetPoint = tl.Position;
         }
     }
     base.HandleInput(gameTime, input);
 }
Example #4
0
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(GameTime gameTime, InputState input)
 {
 }