Hi,
I am trying to create an actor which would follow the mouse wherever it goes. It should be able to do so with and without the left button pressed down. The code I used was:
However, the code only worked when the left button is not pressed down. What are the problems and how can I fix them?
1 2 3 4 5 | if (Greenfoot.mouseMoved( null )) { MouseInfo mouse = Greenfoot.getMouseInfo(); setLocation(mouse.getX(), mouse.getY()); } |