I have a method check(int mouseX, int mouseY) which checks if the mouse is within a square buttons bounds. To be specific, my button is at 50 x 50 y with a width of 50 and height of 50.
The detection works fine along the x axis, only showing that it is being hovered over if it is between the x and x + width, however it shows that it is hovered no matter the y position of the mouse, despite the calculation for the x and y being identical:
public final boolean check(int mouseX, int mouseY)
{
if ((mouseX > x && mouseX < x + width) && (mouseY > y && mouseY < y + height))
{
return true;
}
return false;
}
somehow, this method returns true even if the mouseY is greater than y + height or if mouseY is less than y. Printing all of the values associated with the button return the expected values (x = 50, y = 50, width = 50, height = 50).
I have thoroughly tested this and checked all the calls of this method, and printing out the values of various buttons in every possible place.