Defines an action that is designated by some set of buttons and/or keys. The way actions work is that you define a set of buttons and keys that trigger the action. You can then evaluate the action against an InputState which will test to see if any of the buttons or keys are pressed by a player. You can also set a flag that indicates if the action only occurs once when the buttons/keys are first pressed or whether the action should occur each frame. Using this InputAction class means that you can configure new actions based on keys and buttons without having to directly modify the InputState type. This means more customization by your games without having to change the core classes of Game State Management.
Example #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public GameplayScreen()
        {
            TransitionOnTime = TimeSpan.FromSeconds(1.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);

            pauseAction = new InputAction(
                new Buttons[] { Buttons.Start, Buttons.Back },
                new Keys[] { Keys.Escape },
                true);
        }
Example #2
0
        /// <summary>
        /// Creates the PhoneMenuScreen with a particular title.
        /// </summary>
        /// <param name="title">The title of the screen</param>
        public PhoneMenuScreen(string title)
        {
            menuTitle = title;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);

            // Create the menuCancel action
            menuCancel = new InputAction(new Buttons[] { Buttons.Back }, null, true);

            // We need tap gestures to hit the buttons
            EnabledGestures = GestureType.Tap;
        }