pixi.js
    Preparing search index...

    Interface SortMixinAdvanced

    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 their zIndex changes or when new children are added. The mixin includes properties to manage sorting state and methods to sort children explicitly.

    interface SortMixin {
        sortableChildren: boolean;
        sortChildren: () => void;
        zIndex: number;
    }

    Hierarchy

    Index

    Properties

    sortableChildren: boolean

    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.

    Note

    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.

    container.sortableChildren = true;
    
    false
    
    sortChildren: () => void

    Sorts children by zIndex value. Only sorts if container is marked as dirty.

    // Basic sorting
    particles.zIndex = 2; // Will mark as dirty
    container.sortChildren();
    zIndex: number

    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;
    0