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


C# InputState.IsNewMouseButtonRelease方法代码示例

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


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

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

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


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