LogoPixi’VN
pixi-jsInterfaces

Interface: SortMixin

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/sortMixin.d.ts:58

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.

Advanced

Extends

  • Required<SortMixinConstructor>

Properties

_zIndex

> _zIndex: number

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/sortMixin.d.ts:60

Internal


depthOfChildModified

> depthOfChildModified: () => void

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/sortMixin.d.ts:74

Internal

Returns

void


sortableChildren

> sortableChildren: boolean

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/sortMixin.d.ts:48

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.

Example

container.sortableChildren = true;

Default

false

Inherited from

VideoSpriteMemory.sortableChildren


sortChildren

> sortChildren: () => void

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/sortMixin.d.ts:72

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

Returns

void

Example

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

See


sortDirty

> sortDirty: boolean

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/sortMixin.d.ts:32

Internal

Should children be sorted by zIndex at the next render call.

Will get automatically set to true if a new child is added, or if a child's zIndex changes.

Default

false
@internal

Inherited from

VideoSpriteMemory.sortDirty


zIndex

> zIndex: number

Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/sortMixin.d.ts:24

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.

Example

// Add in any order
container.addChild(character, background, foreground);

// Adjust rendering order
background.zIndex = 0;
character.zIndex = 1;
foreground.zIndex = 2;

See

Default

0

Inherited from

VideoSpriteMemory.zIndex