Appendix B. Greenfoot API

The Greenfoot API consists of five classes:

Actor

Actor methods are available to all actor subclasses.

World

World methods are available to the world.

Greenfoot

Used to communicate with the Greenfoot environment itself.

MouseInfo

Provides information about the last mouse event.

GreenfootImage

For image presentation and manipulation.

Class World

World(int worldWidth, int worldHeight, int cellSize)

Construct a new world.

void act()

Act method for the world. Called once per act round.

void addObject (Actor object, int x, int y)

Add an Actor to the world.

GreenfootImage getBackground()

Return the world’s background image.

int getCellSize()

Return the size of a cell (in pixels).

Color getColorAt(int x, int y)

Return the color at the center of the ...

Get Introduction to Programming with Greenfoot: Object–Oriented Programming in Java™ with Games and Simulations, First Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.