I'm starting to develop a game and I need to be able to see if my mouse is inside a rectangle, I've tried using .contains for a rectangle but i can't seem to get it to work, i'll paste my code below, any help would be greatly appreciated! :)
public boolean isMouseOver(GameContainer gc){
r = new Rectangle(getX(), getY(),getWidth(),getHeight());
Input input = gc.getInput();
xpos = input.getMouseX();
ypos = input.getMouseY();
return r.contains(xpos, ypos);
}
This is the method i'm trying to use, but it keeps returning false when the mouse is inside the rectangle. obviously, I initiated xpos, ypos, and the rectangle further up and I called the method in the update method of the class i'm trying to use it in.