Advanced
If set to true, the container will sort its children by zIndex
value
when the next render is called, or manually if sortChildren()
is called.
This actually changes the order of elements in the array of children, so it will affect the rendering order.
Also be aware of that this may not work nicely with the addChildAt()
function,
as the zIndex
sorting may cause the child to automatically sorted to another position.
Sorts children by zIndex value. Only sorts if container is marked as dirty.
The zIndex of the container.
Controls the rendering order of children within their parent container.
A higher value will mean it will be moved towards the front of the rendering order.
// Add in any order
container.addChild(character, background, foreground);
// Adjust rendering order
background.zIndex = 0;
character.zIndex = 1;
foreground.zIndex = 2;
The SortMixin interface provides methods and properties for sorting children of a container based on their
zIndex
values. It allows for automatic sorting of children when theirzIndex
changes or when new children are added. The mixin includes properties to manage sorting state and methods to sort children explicitly.