Skip to content

LayerSortFn

LayerSortFn = (c) => number

Defined in: renderer/src/LayerDef.ts:23

Depth-key function applied to a layer’s children before each render. Receives a Pixi Container and returns the paint order key — lower values render first (behind), higher values render on top. Identical semantics to writing container.zIndex = key by hand, but applied to every child of the layer each frame.

Default behaviour (no sort) is insertion order — entities render in the order their visual containers were added. Use ySort for the classic top-down 2D depth rule, or compose your own depth-key for isometric / layered-depth setups.

The key is written to container.zIndex by DisplaySystem after transform sync, then Pixi’s own render-time sortChildren() orders the layer by zIndex — so the resulting paint order is exactly what Pixi shows for any manually-zIndexed scene, no separate sort path.

Container

number