Nanfeng

Notes on software development, code, and curious ideas

Controlling Node Order in Cocos2d-x Lua

Set a node’s local Z order with:

1
node:setLocalZOrder(0)

Among sibling nodes, a larger local Z-order value is normally drawn above a smaller one. This affects ordering under the same parent; it is not a global layer shared across unrelated branches of the scene graph.

When siblings have the same Z order, their arrival or child order may decide which is drawn later. Use a small, documented range of layer constants rather than scattered unexplained numbers.

+