How to make an object move wherever your mouse moves -- Greenfoot programming
Find other posts in the same category: |


This is covered in the video tutorial on accepting mouse input.

Here is the code you use.

public class Smiley extends Actor
public void act()
if (Greenfoot.mouseMoved(null) ) {
MouseInfo mouse = Greenfoot.getMouseInfo();
setLocation (mouse.getX(), mouse.getY());

Next Book Page

To see posts on the same topic, click the links below the name of the author at the top of this page.