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


C# InputState.IsNewLeftMouseClick方法代码示例

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


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

示例1: HandleInput

        public override void HandleInput(GameTime gameTime, InputState inputState)
        {
            if (menuAction.Evaluate(inputState))
            {
                Manager.AddScreen(new MapEditorMenuScreen());
            }

            if (inputState.IsNewLeftMouseClick())
            {
                editor.CycleNode(inputState.GetMousePosition());
            }
        }
开发者ID:Grahamcraker,项目名称:Project_Greenhorn,代码行数:12,代码来源:MapEditorScreen.cs

示例2: HandleInput

        public override void HandleInput(InputState input)
        {
            Vector2 mouse = new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y);
            Rectangle mouseRec = new Rectangle((int)mouse.X, (int)mouse.Y, 1, 1);
            Rectangle bounds = new Rectangle((int)Position.X, (int)Position.Y,
                Texture.Width, Texture.Height);

            if (IsEnabled) {
                IsMouseOver = bounds.Contains(mouseRec);

                if (IsMouseOver && input.IsNewLeftMouseClick()) {
                    IsSelected = true;
                }

                if (IsSelected && !IsMouseOver) {
                    if (input.IsNewRightMouseClick()) {
                        IsSelected = false;
                    }
                }
            }
        }
开发者ID:Righteous-Noodle,项目名称:Eva-Frontier,代码行数:21,代码来源:Button.cs

示例3: HandleInput

        public override void HandleInput(GameTime gameTime, InputState inputState)
        {
            if (pauseAction.Evaluate(inputState))
            {
                PauseMenuScreen screen = new PauseMenuScreen();
                screen.IsPopup = true;
                Manager.AddScreen(screen);
            }

            if (spawnNightmareAction.Evaluate(inputState))
            {
                level.CreateNightmare();
            }

            if (inputState.IsNewLeftMouseClick())
            {
                level.CreateTower(inputState.GetMousePosition());
            }
        }
开发者ID:Grahamcraker,项目名称:Project_Greenhorn,代码行数:19,代码来源:GameplayScreen.cs

示例4: HandleInput

        public override void HandleInput(InputState input)
        {
            // previous entry
            if (input.IsMenuUp(ControllingPlayer))
            {
                useMouse = false;

                selectedEntry--;

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

                if (!menuEntries[selectedEntry].Enabled && selectedEntry >= 0)
                {
                    for (int i = selectedEntry; i >= 0; i--)
                    {
                        if (menuEntries[i].Enabled)
                        {
                            selectedEntry = i;
                            break;
                        }
                    }

                    return;
                }
            }

            // next entry
            if (input.IsMenuDown(ControllingPlayer))
            {
                useMouse = false;

                selectedEntry++;

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

                if (!menuEntries[selectedEntry].Enabled && selectedEntry < menuEntries.Count)
                {
                    for (int i = selectedEntry; i < menuEntries.Count - 1; i++)
                    {
                        if (menuEntries[i].Enabled)
                        {
                            selectedEntry = i;
                            break;
                        }
                    }
                    return;
                }
            }

            if (input.LastMouseState.X != mousePos.X || input.LastMouseState.Y != mousePos.Y)
            {
                useMouse = true;
            }

            for (int i = 0; i < menuEntries.Count; i++)
            {
                if (input.LastMouseState.Y > menuEntries[i].Position.Y - Assets.menuFont.LineSpacing / 2 &&
                    input.LastMouseState.Y < menuEntries[i].Position.Y + Assets.menuFont.LineSpacing / 2 &&
                    input.LastMouseState.X > menuEntries[i].Position.X &&
                    input.LastMouseState.X < menuEntries[i].Position.X + Assets.menuFont.MeasureString(menuEntries[i].Text).X && useMouse)
                {
                    selectedEntry = i;
                }
            }

            // 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))
            {
                //if (OptionsFile.IsSound())
                //    Assets.menuSelectSound.Play();
                OnSelectEntry(selectedEntry, playerIndex);
            }
            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                //if (OptionsFile.IsSound())
                //    Assets.menuSelectSound.Play();
                OnCancel(playerIndex);
            }
            else if (input.IsNewLeftMouseClick())
            {
                for (int i = 0; i < menuEntries.Count; i++)
                {
                    if (input.LastMouseState.Y > menuEntries[i].Position.Y &&
                        input.LastMouseState.Y < menuEntries[i].Position.Y + Assets.menuFont.LineSpacing)
                    {
                        //if (OptionsFile.IsSound())
                        //    Assets.menuSelectSound.Play();

                        OnSelectEntry(i, playerIndex);
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:JoshuaKennedy,项目名称:DarkHavoc,代码行数:101,代码来源:MenuScreen.cs


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