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.
Esempio n. 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MenuScreen(string menuTitle)
        {
            this.menuTitle = menuTitle;

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

            menuUp = new InputAction(new Buttons[] {
            Buttons.DPadUp,
            Buttons.LeftThumbstickUp
            }, new Keys[] { Keys.Up }, true);
            menuDown = new InputAction(new Buttons[] {
            Buttons.DPadDown,
            Buttons.LeftThumbstickDown
            }, new Keys[] { Keys.Down }, true);
            menuSelect = new InputAction(new Buttons[] {
            Buttons.A,
            Buttons.Start
            }, new Keys[] {
            Keys.Enter,
            Keys.Space
            }, true);
            menuCancel = new InputAction(new Buttons[] {
            Buttons.B,
            Buttons.Back
            }, new Keys[] { Keys.Escape }, true);
        }
        /// <summary>
        /// Constructor lets the caller specify whether to include the standard
        /// "A=ok, B=cancel" usage text prompt.
        /// </summary>
        public MessageBoxScreen(string message, bool includeUsageText)
        {
            const string usageText = " A button, Space, Enter = ok " + "B button, Esc = cancel";

            if (includeUsageText)
            {
                this.message = message + usageText;
            }
            else
            {
                this.message = message;
            }

            IsPopup = true;

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

            menuSelect = new InputAction(new Buttons[] {
            Buttons.A,
            Buttons.Start
            }, new Keys[] {
            Keys.Space,
            Keys.Enter
            }, true);
            menuCancel = new InputAction(new Buttons[] {
            Buttons.B,
            Buttons.Back
            }, new Keys[] {
            Keys.Escape,
            Keys.Back
            }, true);
        }