Skip to content

addOrder()

Add an object to the collection on a given layer.

Same as add(), but also sets the object's layer within the collection. Layers run from smallest to largest, where 0 is closest to the front.

Parameters

Once an object collection has been created, you can use the following function:

collection.addOrder(item, order)
collection.addOrder(item, order, x, y)
Parameter Type Default Description
item Drawable required The object to add.
order int required The layer to place it on; 0 is closest to the front.
x int or float None The horizontal position, in pixels. Defaults to the object's current position.
y int or float None The vertical position, in pixels. Defaults to the object's current position.