Exemplo n.º 1
0
        public void Update()
        {
            var mouseState = Mouse.GetState();

            if (CheckMouseOver())
            {
                if (_buttonState == UiButtonState.Hover && mouseState.LeftButton == ButtonState.Pressed)
                {
                    _buttonState = UiButtonState.Pressed;
                }
                else if (mouseState.LeftButton == ButtonState.Released && _buttonState == UiButtonState.Pressed)
                {
                    _buttonState = UiButtonState.Hover;
                    Click();
                }
                else if (mouseState.LeftButton == ButtonState.Released)
                {
                    if (_buttonState == UiButtonState.OutOfButton)
                    {
                        PlayHoverSoundIfExists();
                    }

                    _buttonState = UiButtonState.Hover;
                }
            }
            else
            {
                _buttonState = UiButtonState.OutOfButton;
            }
        }
Exemplo n.º 2
0
 protected ButtonBase(Texture2D texture, Rectangle rect)
 {
     Texture      = texture;
     Rect         = rect;
     _buttonState = UiButtonState.OutOfButton;
 }