I have just started using greenfoot for school and I would like to create a game like this one: http://www.scirra.com/arcade/action/455/squared but I am having trouble getting the actor/object to follow my mouse. Like the black square does in the mentioned game. I have tried this code so far but to no avail.
MouseInfo mouse = Greenfoot.getMouseInfo();
setLocation(mouse.getX(), mouse.getY());
if (mouse != null)
{
setLocation(mouse.getX(), mouse.getY());
}