Greenfoot: The Greenfoot Class

This contains a number of useful methods

Mouse

mouseClicked()

mouseDragEnded()

mouseDragged()

mouseMoved()

mousePressed()

getMouseInfo

Use new scenario

getRandomNumber()

To get a single random number in the range 0-9:

int x = Greenfoot.getRandomNumber (10);

To generate the x and y values for a random location inside the screen area of the world:

int x = Greenfoot.getRandomNumber (getWorld().getWidth())

int y = Greenfoot.getRandomNumber (getWorld().getHeight())

 

Home Page