Hi!
I have made complex things with get X get Y and get rotation yet I have no idea how to make an event so that when the mouse clicks on an object it does something. Can anyone help?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class bear here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class bear extends Actor
{
/**
* Act - do whatever the bear wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(Greenfoot.mouseClicked(this)) {
move(4);
}
}
}if (Greenfoot.mouseClicked(this)) {
MouseInfo info = Greenfoot.getMouseInfo();
setLocation(info.getX(), info.getY());
}