public override void Update()
        {
            newstate = Mouse.GetState();

            if (MouseTouching.Rect(newstate, rect))
            {
                if (newstate.LeftButton == ButtonState.Pressed && oldstate.LeftButton != ButtonState.Pressed)
                {
                    OnClick();
                }

                hovering = true;
            }
            else
            {
                hovering = false;
            }

            oldstate = newstate;
            base.Update();
        }
        public override void Update()
        {
            MouseState mouse = Mouse.GetState();

            if (MouseTouching.Rect(mouse, rect))
            {
                hovering = true;
                if (mouse.LeftButton == ButtonState.Pressed)
                {
                    switch (lockOn)
                    {
                    case AxisLockOn.X:
                        position.X = mouse.Position.X - texture.Width / 2;
                        break;

                    case AxisLockOn.Y:
                        position.Y = mouse.Position.Y - texture.Height / 2;
                        break;

                    case AxisLockOn.none:
                        position.X = mouse.Position.X - texture.Width / 2;
                        position.Y = mouse.Position.Y - texture.Height / 2;
                        break;

                    default:
                        position.X = mouse.Position.X;
                        position.Y = mouse.Position.Y;
                        break;

                        //nice codebase ;)
                    }
                    dragging = true;
                }
            }
            else
            {
                hovering = false;
                dragging = false;
            }
        }
Beispiel #3
0
        public override void Update()
        {
            mouse = Mouse.GetState();

            if (focused)
            {
                if (MouseTouching.Rect(mouse, rect))
                {
                    boxColor = hoverColor;
                }
                else
                {
                    boxColor = defaultColor;
                }
            }
            else
            {
                boxColor = disableColor;
            }

            base.Update();
        }