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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.