(CGA) Layering Objects in the World Lesson

Layering Objects in the World

Game objects may need to be in a certain order in the world.  To layer objects, Greenfoot provides a setPaintOrder(java.lang.Class classes) method.  Use this method to specify the paint order for the objects in the world.

code block:

void
setPaintOrder (java.lang.Class... classes) Set the paint order of objects in the world.
setPaintOrder
public void setPaintOrder (java.lang.Class... classes)
Set the paint order of objects in the world. Paint order is specified by class: objects of one class will always be painted on top of objects of some other 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.
Parameters:
classes
-
The classes in desired paint order

[CC BY 4.0] UNLESS OTHERWISE NOTED | IMAGES: LICENSED AND USED ACCORDING TO TERMS OF SUBSCRIPTION