示例#1
0
        public void Update(GameTime gameTime, KinectInterface gameInput)
        {
            // Cursors positions
            Rectangle[] cursors = gameInput.GetHandCursorsBoundingBoxes();

            // Look if user "cursor" is currently hover
            if (_boundingBox.Intersects(cursors[KinectInterface.LEFT_HAND]) || _boundingBox.Intersects(cursors[KinectInterface.RIGHT_HAND]))
            {
                _hover = true;
                _textCurrentColor = _textSelectedColor;
            }
            else
            {
                // Reset current status
                _hover = false;
                _hoverTime = 0.0f;
                _pressed = false;
                _textCurrentColor = _textNormalColor;
            }
            // If currently hover, we measure the total time spent hover, and set the button as selected if the minimal "selection time" was reached
            if(_hover && !_pressed)
            {
                // Coompute total time
                float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
                _hoverTime += dt;

                // Selection time is reached !
                if (_hoverTime >= TextButton.BUTTON_SELECTION_TIME)
                {
                    _pressed = true;
                    Console.WriteLine("BUTTON " + _buttonText + " IS PRESSED");
                }
            }
        }