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


C# InputState.IsNewMouseButtonPress方法代码示例

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


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

示例1: HandleInput


//.........这里部分代码省略.........
                    ScreenManager.Game.IsMouseVisible = true;
                }

                if (keyboardState.IsKeyDown(Keys.NumPad3) || keyboardState.IsKeyDown(Keys.D3))
                {
                    _hero.selectAbility(AbilityType.GRAVITY_HOLE);
                    ScreenManager.Game.IsMouseVisible = true;
                }

                if (keyboardState.IsKeyDown(Keys.NumPad4) || keyboardState.IsKeyDown(Keys.D4))
                {
                    _hero.selectAbility(AbilityType.GRAVITY_FLIP);
                    ScreenManager.Game.IsMouseVisible = false;
                }

                if (keyboardState.IsKeyDown(Keys.Left))
                {
                    _camera.MoveCamera(ConvertUnits.ToSimUnits(new Vector2(-50f, 0f)));
                }
                if (keyboardState.IsKeyDown(Keys.Right))
                {
                    _camera.MoveCamera(ConvertUnits.ToSimUnits(new Vector2(50f, 0f)));
                }
                if (keyboardState.IsKeyDown(Keys.Up))
                {
                    _camera.MoveCamera(ConvertUnits.ToSimUnits(new Vector2(0f, -50f)));
                }
                if (keyboardState.IsKeyDown(Keys.Down))
                {
                    _camera.MoveCamera(ConvertUnits.ToSimUnits(new Vector2(0f, 50f)));
                }

                if (keyboardState.IsKeyDown(Keys.LeftControl) || keyboardState.IsKeyDown(Keys.RightControl))
                {
                    if (keyboardState.IsKeyDown(Keys.PageUp))
                    {
                        _camera.Zoom += .05f;
                    }

                    if (keyboardState.IsKeyDown(Keys.PageDown))
                    {
                        _camera.Zoom -= .05f;
                    }

                    if (keyboardState.IsKeyDown(Keys.D0) || keyboardState.IsKeyDown(Keys.NumPad0))
                    {
                        _camera.Zoom = 1f;
                        _camera.Position = _hero.getSimPosition();
                    }

                    if (keyboardState.IsKeyDown(Keys.OemTilde))
                    {
                        //if (!lastKeyboardState.IsKeyDown(Keys.OemTilde))
                        {
                            toggleDebugViewXNA();
                            _debugMode = !_debugMode;
                        }
                        lastKeyboardState = keyboardState;
                    }
                    if (keyboardState.IsKeyDown(Keys.OemPlus))
                    {
                        //if (!lastKeyboardState.IsKeyDown(Keys.OemPlus))
                            loadNextLevel();
                        lastKeyboardState = keyboardState;
                    }
                }

                if (_hero.getSelectedAbility() == AbilityType.GRAVITY_HOLE
                    && input.IsNewMouseButtonPress(MouseButtons.LeftButton))
                {

                    Vector2 position = _camera.ConvertScreenToWorld(input.Cursor);

                    double distance = calculateDistanceOfVectors(position, _hero.getSimPosition());
                    if (distance < 10)
                    {
                        lastMousePosition = position;
                        _hero.performGravityHole(position);
                    }

                    //_hero.setSimPosition(position);

                }
                else if (_hero.getSelectedAbility() == AbilityType.GRAVITY_SPHERE && input.IsNewMouseButtonPress(MouseButtons.LeftButton))
                {

                    Vector2 position = _camera.ConvertScreenToWorld(input.Cursor);
                    clickedPosition = position;

                    double distance = calculateDistanceOfVectors(position, _hero.getSimPosition());
                    Console.WriteLine(distance);
                    //limitting radius
                    if (distance < 10)
                    {
                        _hero.performGravitySphere();

                    }
                }
            }
        }
开发者ID:res09ggm,项目名称:ucimobile,代码行数:101,代码来源:GameplayScreen.cs

示例2: HandleMouseEvents

        private void HandleMouseEvents(InputState input)
        {
            Vector2 position = this.Camera.ConvertScreenToWorld(input.Cursor);
            Fixture fix = this.World.TestPoint(position);
            AxiosGameObject gobj;
            if (fix != null && fix.UserData != null && fix.UserData is AxiosGameObject)
            {
                gobj = (AxiosGameObject)fix.UserData;

                if (gobj != null && gobj != prevobj)
                {
                    gobj.OnMouseHover(this, input);

                    if (prevobj != gobj && prevobj != null)
                        prevobj.OnMouseLeave(this, input);
                }
                else if (gobj != null)
                {
                    if (input.IsNewMouseButtonRelease(MouseButtons.LeftButton))
                    {
                        if (prevobj != null)
                            prevobj.OnFocusLeave(this, input);
                        gobj.OnFocusEnter(this, input);
                        gobj.OnMouseUp(this, input);
                        prevfocusobj = gobj;
                        //prevobj = gobj;
                    }

                    if (input.IsNewMouseButtonPress(MouseButtons.LeftButton))
                        gobj.OnMouseDown(this, input);
                }

                if (gobj != null)
                    prevobj = gobj;
            }
            else
            {
                if (prevobj != null)
                    prevobj.OnMouseLeave(this, input);
                if (input.IsNewMouseButtonPress(MouseButtons.LeftButton) && prevfocusobj != null)
                {
                    prevfocusobj.OnFocusLeave(this, input);
                    prevfocusobj = null;
                }
                prevobj = null;
            }

            Vector2 uiobjpos;
            //Rectangle uirect;
            AxiosRectangle uirect;
            bool foundobject = false;
            Vector2 mousepos = this.Camera.ConvertScreenToWorld(input.Cursor);
            //Vector2 objpos;
            //System.Diagnostics.Debugger.Break();
            AxiosRectangle mousrect = new AxiosRectangle(mousepos.X, mousepos.Y, ConvertUnits.ToSimUnits(25), ConvertUnits.ToSimUnits(25));
            foreach(AxiosUIObject uiobject in _uiobjects)
            {
                uiobjpos = uiobject.Position;
                //objpos = this.Camera.ConvertScreenToWorld(uiobjpos);

                uirect = new AxiosRectangle(ConvertUnits.ToSimUnits(uiobjpos.X), ConvertUnits.ToSimUnits(uiobjpos.Y), ConvertUnits.ToSimUnits(uiobject.Width), ConvertUnits.ToSimUnits(uiobject.Height));

                if (uirect.Intersect(mousrect))
                {

                    if (input.IsNewMouseButtonPress(MouseButtons.LeftButton))
                    {
                        uiobject.OnMouseDown(this, input);
                    }

                    if (input.IsNewMouseButtonRelease(MouseButtons.LeftButton))
                    {
                        //System.Diagnostics.Debugger.Break();
                        if (prevuifocusobj != uiobject)
                        {
                            uiobject.OnFocusEnter(this, input);
                            if (prevuifocusobj != null)
                                prevuifocusobj.OnFocusLeave(this, input);
                            prevuifocusobj = uiobject;
                        }
                        uiobject.OnMouseUp(this, input);
                    }

                    if (prevuiobj != uiobject)
                    {
                        //System.Diagnostics.Debugger.Break();
                        uiobject.OnMouseHover(this, input);
                        if (prevuiobj != null)
                            prevuiobj.OnMouseLeave(this, input);
                        prevuiobj = uiobject;
                    }
                    foundobject = true;
                    break;

                }
            }
            if (!foundobject && prevuiobj != null)
            {
                //mouse moved away from object
                prevuiobj.OnMouseLeave(this, input);
//.........这里部分代码省略.........
开发者ID:nadams810,项目名称:axiosengine,代码行数:101,代码来源:AxiosGameScreen.cs

示例3: HandleMouseInput

 public override void HandleMouseInput(InputState input)
 {
     PlayerIndex player;
     //check for any mouse clicks and select any entries that were clicked
     if (input.IsNewMouseButtonPress(MouseButtons.LeftButton, out player))
     {
         // TODO: Check mouse location
         //Vector2 clickLocation = new Vector2(input.CurrentMouseState.Position.X * ScreenManager.Scaler.Scale.X / (ScreenManager.Game as GoblinsGame.TheGame).ScreenScale, input.CurrentMouseState.Position.Y * ScreenManager.Scaler.Scale.Y / (ScreenManager.Game as GoblinsGame.TheGame).ScreenScale);
         //CheckMenuUnderPoint(clickLocation.ToPoint());
     }
 }
开发者ID:VoronFX,项目名称:SummerPractice,代码行数:11,代码来源:MenuScreen.cs

示例4: HandleCursor

        public virtual void HandleCursor(InputState input)
        {
            PlayerIndex player;
            Vector2 position = Camera.ConvertScreenToWorld(input.Cursor);

            if ((input.IsNewButtonPress(Buttons.A, PlayerIndex.One, out player) ||
                    input.IsNewMouseButtonPress(MouseButtons.LeftButton)) &&
                _fixedMouseJoint == null)
            {
                Fixture savedFixture = World.TestPoint(position);
                if (savedFixture != null && savedFixture.UserData is SimpleAxiosGameObject && ((SimpleAxiosGameObject)(savedFixture.UserData)).AllowAutomaticMouseJoint)
                {
                    Body body = savedFixture.Body;
                    _fixedMouseJoint = new FixedMouseJoint(body, position);
                    _fixedMouseJoint.MaxForce = 1000.0f * body.Mass;
                    World.AddJoint(_fixedMouseJoint);
                    body.Awake = true;
                }
            }

            if ((input.IsNewButtonRelease(Buttons.A, ControllingPlayer.Value, out player) ||
                    input.IsNewMouseButtonRelease(MouseButtons.LeftButton)) &&
                _fixedMouseJoint != null)
            {
                World.RemoveJoint(_fixedMouseJoint);
                _fixedMouseJoint = null;
            }

            if (_fixedMouseJoint != null)
            {
                _fixedMouseJoint.WorldAnchorB = position;
            }
        }
开发者ID:nadams810,项目名称:axiosengine,代码行数:33,代码来源:PhysicsGameScreen.cs

示例5: HandleInput

        /// <summary>
        /// Input helper method provided by GameScreen.  Packages up the various /// input values for ease of use.
        /// </summary>
        /// <param name="input">The state of the gamepads</param>
        public override void HandleInput(InputState input)
        {
            PlayerIndex player;

            if (input == null)
                throw new ArgumentNullException("input");

            if (input.IsNewKeyPress(Keys.F12, out player))
            {
                if (!Windows.UI.ViewManagement.ApplicationView
                        .GetForCurrentView().IsFullScreen)
                    Windows.UI.ViewManagement.ApplicationView
                        .GetForCurrentView().TryEnterFullScreenMode();
                else
                    Windows.UI.ViewManagement.ApplicationView
                        .GetForCurrentView().ExitFullScreenMode();
            }

            if (gameOver)
            {
                if (input.IsPauseGame())
                {
                    FinishCurrentGame();
                }

                if (input.IsNewKeyPress(Keys.Space, out player)
                    || input.IsNewKeyPress(Keys.Enter, out player))
                {
                    FinishCurrentGame();
                }

                if (input.IsNewGamePadButtonPress(Buttons.A, out player)
                    || input.IsNewGamePadButtonPress(Buttons.Start, out player))
                {
                    FinishCurrentGame();
                }

                if (input.IsNewMouseButtonPress(MouseButtons.LeftButton,
                                                out player))
                {
                    FinishCurrentGame();
                }

                foreach (GestureSample gestureSample in input.Gestures)
                {
                    if (gestureSample.GestureType == GestureType.Tap)
                    {
                        FinishCurrentGame();
                    }
                }

                return;
            }
        }
开发者ID:VoronFX,项目名称:SummerPractice,代码行数:58,代码来源:GameplayScreenBattle.cs


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