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


C# InputState.IsMenuSelect方法代码示例

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


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

示例1: HandleInput

 public override void HandleInput(InputState input)
 {
     PlayerIndex player;
     if (input.IsMenuSelect(null, out player))
     {
         exit = true;
         ControllingPlayer = player;
     }
     base.HandleInput(input);
 }
开发者ID:kmatzen,项目名称:EECS-494-Final-Project,代码行数:10,代码来源:TitleScreen.cs

示例2: HandleInput

        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;

            // 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 our Accepted and
            // Cancelled events, so they can tell which player triggered them.
            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }
            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }
        }
开发者ID:urvaius,项目名称:SaturnsTurn2,代码行数:29,代码来源:MessageBoxScreen.cs

示例3: 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))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }

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

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }

            // 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.
            PlayerIndex playerIndex;

            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {
                OnSelectEntry(selectedEntry, playerIndex);
            }
            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                OnCancel(playerIndex);
            }
        }
开发者ID:kmatzen,项目名称:EECS-494-Final-Project,代码行数:40,代码来源:MenuScreen.cs

示例4: HandleInput

        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // we cancel the current menu screen if the user presses the back button
            PlayerIndex player;
            if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
            {
                OnCancel(player);
            }

			if (input.IsMenuDown(ControllingPlayer)) {
				if (selectedEntry < menuEntries.Count - 1)
					selectedEntry += 1;
			}

			if (input.IsMenuUp(ControllingPlayer)) {
				if (selectedEntry > 0)
					selectedEntry -= 1;
			}

			if (input.IsMenuSelect(ControllingPlayer, out player)) {
				menuEntries[selectedEntry].OnSelectEntry(player);
			}

			if (input.MouseGesture.HasFlag(MouseGestureType.LeftClick)) {

				Point clickLocation = new Point((int)input.CurrentMousePosition.X, (int)input.CurrentMousePosition.Y);
				// iterate the entries to see if any were tapped
				for (int i = 0; i < menuEntries.Count; i++)
				{
					MenuEntry menuEntry = menuEntries[i];

					if (GetMenuEntryHitBounds(menuEntry).Contains(clickLocation))
					{
						// select the entry. since gestures are only available on Windows Phone,
						// we can safely pass PlayerIndex.One to all entries since there is only
						// one player on Windows Phone.
						OnSelectEntry(i, PlayerIndex.One);
					}
				}
			}

			if (input.MouseGesture.HasFlag(MouseGestureType.Move)) {

				Point clickLocation = new Point((int)input.CurrentMousePosition.X, (int)input.CurrentMousePosition.Y);
				// iterate the entries to see if any were tapped
				for (int i = 0; i < menuEntries.Count; i++)
				{
					MenuEntry menuEntry = menuEntries[i];

					if (GetMenuEntryHitBounds(menuEntry).Contains(clickLocation))
					{
						// select the entry. since gestures are only available on Windows Phone,
						// we can safely pass PlayerIndex.One to all entries since there is only
						// one player on Windows Phone.
						//OnSelectEntry(i, PlayerIndex.One);
						selectedEntry = i;
					}
				}
			}

            // look for any taps that occurred and select any entries that were tapped
            foreach (GestureSample gesture in input.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    // convert the position to a Point that we can test against a Rectangle
                    Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);

                    // iterate the entries to see if any were tapped
                    for (int i = 0; i < menuEntries.Count; i++)
                    {
                        MenuEntry menuEntry = menuEntries[i];

                        if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
                        {
                            // select the entry. since gestures are only available on Windows Phone,
                            // we can safely pass PlayerIndex.One to all entries since there is only
                            // one player on Windows Phone.
                            OnSelectEntry(i, PlayerIndex.One);
                        }
                    }
                }
            }
        }
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:88,代码来源:MenuScreen.cs

示例5: HandleInput

		/// <summary>
		/// Handles user input for all the local gamers in the session. Unlike most
		/// screens, which use the InputState class to combine input data from all
		/// gamepads, the lobby needs to individually mark specific players as ready,
		/// so it loops over all the local gamers and reads their inputs individually.
		/// </summary>
		public override void HandleInput (InputState input)
		{
			foreach (LocalNetworkGamer gamer in networkSession.LocalGamers) {
				PlayerIndex playerIndex = gamer.SignedInGamer.PlayerIndex;

				PlayerIndex unwantedOutput;

				if (input.IsMenuSelect (playerIndex, out unwantedOutput)) {
					HandleMenuSelect (gamer);
				} else if (input.IsMenuCancel (playerIndex, out unwantedOutput)) {
					HandleMenuCancel (gamer);
				}
			}
		}
开发者ID:tyschacht,项目名称:MonoGame-Samples,代码行数:20,代码来源:LobbyScreen.cs

示例6: HandleInput

        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            var touch = input.TouchState;

            var rect = new Rectangle(0,0,100,30);
            if (touch.Count == 1 ) {
                for (int i = 0; i < menuEntries.Count; i++){
                    rect.X = (int)menuEntries[i].Position.X;
                    rect.Y = (int)menuEntries[i].Position.Y;
                    selectedEntry = i;
                    if (rect.Contains((int)touch[0].Position.X, (int)touch[0].Position.Y)){
                        OnSelectEntry(selectedEntry, 0);
                        break;
                    }
                }
            }

            // Move to the previous menu entry?
            if (input.IsMenuUp(ControllingPlayer))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }

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

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }

            // 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.
            PlayerIndex playerIndex;

            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {
                OnSelectEntry(selectedEntry, playerIndex);
            }
            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                OnCancel(playerIndex);
            }
        }
开发者ID:Clancey,项目名称:BMX_MonoGame,代码行数:55,代码来源:MenuScreen.cs

示例7: 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

示例8: HandleInput

        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // 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.
            PlayerIndex playerIndex;

            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {
                //OnSelectEntry(selectedEntry, playerIndex);
                //ExitScreen();
                showControls = !showControls;
            }
            if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                //OnCancel(playerIndex);
                ExitScreen();
            }
        }
开发者ID:kmatzen,项目名称:EECS-494-Final-Project,代码行数:25,代码来源:ControlsScreen.cs

示例9: HandleInput

        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;
            Viewport viewport = ScreenManager.Game.GraphicsDevice.Viewport;
            Vector2 halfSize = new Vector2(viewport.Width, viewport.Height)/2;
            // 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 our Accepted and
            // Cancelled events, so they can tell which player triggered them.
            if (input.IsMenuSelect())
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, new EventArgs());

                ExitScreen();
            }
            else if (input.IsMenuCancel())
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, new EventArgs());

                ExitScreen();
            }

            Point mouseLoc = new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y);

            Rectangle okRect = new Rectangle((int)halfSize.X - 25, (int)halfSize.Y + 25, 50, 50);
            if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
            {
                if (okRect.Contains(mouseLoc)) ExitScreen();
            }
        }
开发者ID:GarethIW,项目名称:LD29,代码行数:38,代码来源:MessageBoxScreen.cs


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