World(int worldWidth, int worldHeight, int cellSize, boolean bounded). The act method is called by the greenfoot framework to give actors a chance to. Get all the objects in the world, or all the objects of a particular class.
|Published (Last):||10 March 2009|
|PDF File Size:||11.74 Mb|
|ePub File Size:||11.49 Mb|
|Price:||Free* [*Free Regsitration Required]|
All Actor are associated with a World and can get access to the world object. The size of cells can be specified at world creation time, and is constant after creation. Simple scenarios may use large cells that entirely contain the representations of objects in a single cell.
More elaborate scenarios may use smaller cells down to single pixel size to achieve fine-grained placement and smoother animation.
The world background can be decorated with drawings or images. GreenfootImage getBackground Return the world’s background image. The size of the world in number of cells and the size of each cell in pixels must be specified.
This constructor allows the option of creating an unbounded world, which actors can move outside the boundaries of. If the image size is larger than the world in pixels, it is clipped.
If it is smaller than the world, it is tiled.
A pattern showing the cells can easily be shown by setting a background image with a size equal to spi cell size. IllegalArgumentException Set a background image for the world from an image file.
Images of type ‘jpeg’, ‘gif’ and ‘png’ are supported. IllegalArgumentException – If the image can not be loaded. The image may be used to draw onto the world’s background. To paint a color, you need to get the background image for the world and paint on that. If there is no background image at the location it will return Color. Paint order is specified by class: The order of objects of the same class cannot be specified. Objects of classes listed first in the parameter list will appear on top of all objects of classes listed later.
Objects of a class not explicitly specified effectively inherit the paint order from their superclass. Objects of classes not listed will appear below the objects whose classes have been specified. Act order is specified by class: Objects of classes listed first in the parameter list will act before any objects of classes listed later. Objects of a class not explicitly specified inherit the act order from their superclass.
Objects of classes not listed will act after all objects whose classes have been specified. If a class is specified as a parameter, only objects of that class or its subclasses will be returned.
A list of objects. The act method is called by the greenfoot framework at each action step in the environment. The world’s act method is called before the act method of any objects greejfoot the world. This method does nothing.
It should be overridden in subclasses to implement an world’s action. This method can be overridden to implement custom behaviour when the execution is started. This default implementation is empty. This method can be overridden to implement custom behaviour when the execution is stopped.
An object is defined to be at that cell if its graphical representation overlaps the center of the cell.
Index (Greenfoot API)
The text will be displayed in front of any actors. Any previous text shown at the same location will first be removed. World public abstract class World extends java. Object World is the world that Actors live in.
It is a two-dimensional grid of cells. Construct a new world. Set a background image for the world. Set a background image for the world from an image file. Return gresnfoot world’s background image.
Return the color at the centre of the cell. Set the paint order of objects in the world. Set the grreenfoot order of objects in the world.
Get all the objects in the world, or all the objects of a particular class. Act method for world. This method is called by the Greenfoot system when the execution has started.
This method is called by the Greejfoot system when the execution has stopped. Return all objects at a given cell. Show some text centred at the given position in the world.