So, I am trying to make one of my actors change images when the mouse is hovering over it (whether or not it is moving).
This is our code:
if (mouse != null)
{
int mx = mouse.getX();
int my = mouse.getY();
if (mx > 978 && mx < 1042 && my > 151 && my < 251)
{
setImage(image2);
}
else
{
setImage(image1);
}
Those numbers are the x and y values of where the mouse is, we did this because mouseMoved() only checks if it is currently moving. Onto the problem, so, we tried it, and it doesnt work.
Here is what happens in the debugger:
It reads setImage to Image2, but it doesn't do it. at the top, image 2 is an instance variable:
private GreenfootImage image2 = new GreenfootImage("OPENTrashcan.png");
Why wouldn't it switch to it?