I'm struggling to find a way to get the X and Y co-ordinates of the mouse, as I want to display them on the screen, but I'm getting an error with the showText. I'm probably missing something obvious, because I haven't used Greenfoot to code in two years. Can anyone help?
My code:
I'm not sure if I need to add anything into another class or subclass, so I haven't yet.
import greenfoot.*;
public class MouseInfo
extends java.lang.Object
{
public int getX;
public int getY;
public MouseInfo()
{
}
public void act()
{
location();//location code
}
public void location()
{
showText("X: "+getX, 50, 50);
showText("Y: "+getY, 100, 50);
}
}
