当前位置: 首页>>代码示例>>C#>>正文


C# InputState.IsMenuLeft方法代码示例

本文整理汇总了C#中GameStateManagement.InputState.IsMenuLeft方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.IsMenuLeft方法的具体用法?C# InputState.IsMenuLeft怎么用?C# InputState.IsMenuLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameStateManagement.InputState的用法示例。


在下文中一共展示了InputState.IsMenuLeft方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleInput

        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input.IsMenuCancel())
            {
                OnCancel(null, null);
            }

            if (input.IsMenuUp())
            {
                selectedEntry--;
                if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1;
                while (!menuEntries[selectedEntry].Enabled)
                {
                    selectedEntry--;
                    if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1;
                }
            }
            if (input.IsMenuDown())
            {
                selectedEntry++;
                if (selectedEntry >= menuEntries.Count) selectedEntry = 0;
                while (!menuEntries[selectedEntry].Enabled)
                {
                    selectedEntry++;
                    if (selectedEntry >= menuEntries.Count) selectedEntry = 0;
                }
            }
            if (input.IsMenuLeft()) menuEntries[selectedEntry].Left();
            if (input.IsMenuRight()) menuEntries[selectedEntry].Right();

            if (input.IsMenuSelect()) OnSelectEntry(selectedEntry);
            if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1;
            if (selectedEntry >= menuEntries.Count) selectedEntry = 0;

            Point mouseLocation = ScreenManager.ScaledMousePos;

            for (int i = 0; i < menuEntries.Count; i++)
            {
                MenuEntry menuEntry = menuEntries[i];

                if (GetMenuEntryHitBounds(menuEntry).Contains(mouseLocation))
                {
                    selectedEntry = i;

                    // Mouse left click?
                    if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed)
                    {
                       menuEntry.Click(mouseLocation.X, mouseLocation.Y);
                    }
                }
            }
        }
开发者ID:GarethIW,项目名称:LD29,代码行数:56,代码来源:MenuScreen.cs

示例2: HandleInput

        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // Move to the previous menu entry?
            if (input.IsMenuUp(ControllingPlayer))
            {

                keyPos.Y--;
                if (keyPos.Y < 0)
                {
                    keyPos.Y = keys.Length - 1;
                }
            }

            // Move to the next menu entry?
            if (input.IsMenuDown(ControllingPlayer))
            {

                keyPos.Y++;
                if (keyPos.Y > keys.Length-1)
                {
                    keyPos.Y = 0;
                }
            }

             PlayerIndex playerIndex;

             if (input.IsMenuRight(ControllingPlayer))
             {
                 keyPos.X++;
                 if (keyPos.X > keys[(int)keyPos.Y].Length - 1)
                 {
                     keyPos.X = 0;
                 }
             }

             if (input.IsMenuLeft(ControllingPlayer))
             {
                 keyPos.X--;
                 if (keyPos.X < 0)
                 {
                     keyPos.X = keys[(int)keyPos.Y].Length - 1;
                 }
             }

            // Move to the next menu entry?
               //          public bool IsNewButtonPress(Buttons button, PlayerIndex? controllingPlayer,
             //                                            out PlayerIndex playerIndex)
            if ( input.IsNewButtonPress(Buttons.Y,ControllingPlayer, out playerIndex) )
            {
                playerNameChars[selectedEntry] = ' ';
                selectedEntry = Math.Min(selectedEntry + 1, numNameChars - 1);

                playerNameMenuEntry.Text = (new string(playerNameChars, 0, playerNameChars.Length));
            }

            // Accept or cancel the menu? We pass in our ControllingPlayer, which may
            // either be null (to accept input from any player) or a specific index.
            // If we pass a null controlling player, the InputState helper returns to
            // us which player actually provided the input. We pass that through to
            // OnSelectEntry and OnCancel, so they can tell which player triggered them.

            if (input.IsNewButtonPress(Buttons.A, ControllingPlayer, out playerIndex) )
            {
                OnSelectEntry(selectedEntry, playerIndex);
            }
            else if (input.IsNewButtonPress(Buttons.B, ControllingPlayer, out playerIndex) ||
                input.IsNewButtonPress(Buttons.X, ControllingPlayer, out playerIndex)
                )
            {
                OnCancel(playerIndex);
            }
            else if (input.IsNewButtonPress(Buttons.Start, ControllingPlayer, out playerIndex))
            {
                CompleteEntry();
            }
        }
开发者ID:kmatzen,项目名称:EECS-494-Final-Project,代码行数:80,代码来源:NameEntryScreen.cs


注:本文中的GameStateManagement.InputState.IsMenuLeft方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。