예제 #1
0
        public void Update(float deltaTime, Point mousePosition, float screenWidth, float screenHeight, bool leftClicked)
        {
            if (leftClicked)
            {
                //Get upper left point of sliderHead
                Point headCoords = CoordinateTransformation.GL_to_Screen_Coords(Position + new Vector2(-Size.X / 2, Size.Y / 2), screenWidth, screenHeight);
                //Get sliderHead size
                Point headSize = CoordinateTransformation.GL_Size_To_Screen_Size(Size, screenWidth, screenHeight);

                //Make rectangles relative to screen to check for intersection
                Rectangle headRect  = new Rectangle(headCoords.X, headCoords.Y, headSize.X, headSize.Y);
                Rectangle mouseRect = new Rectangle(mousePosition, new Size(10, 10));

                if (headRect.IntersectsWith(mouseRect))
                {
                    Position = new Vector2(CoordinateTransformation.Screen_to_GL_Coords(mousePosition, screenWidth, screenHeight).X, Position.Y);
                }
            }
        }
예제 #2
0
        public void Update(float deltaTime, Point mousePosition, float screenWidth, float screenHeight, bool leftClicked)
        {
            if (leftClicked && !leftClickedLastFrame)
            {
                //Get upper left point of checkbox
                Point checkboxCoords = CoordinateTransformation.GL_to_Screen_Coords(Position + new Vector2(-Size.X / 2, Size.Y / 2), screenWidth, screenHeight);
                //Get checkbox size
                Point checkboxSize = CoordinateTransformation.GL_Size_To_Screen_Size(Size, screenWidth, screenHeight);

                //Make rectangles relative to screen to check for intersection
                Rectangle checkboxRect = new Rectangle(checkboxCoords.X, checkboxCoords.Y, checkboxSize.X, checkboxSize.Y);
                Rectangle mouseRect    = new Rectangle(mousePosition, new Size(10, 10));

                if (checkboxRect.IntersectsWith(mouseRect))
                {
                    CheckBoxTick.Activated = !CheckBoxTick.Activated;
                    System.Console.WriteLine("Checkbox " + CheckBoxTick.Activated);
                }
            }

            leftClickedLastFrame = leftClicked;
        }