Wednesday, October 30, 2013

Cocos2D Draw Order

In summary:

  • If within same parent and same Z order, then nodes that are added first will be drawn first, followed by the ones added later in sequence.
  • If within the same parent and different Z order, then it's according to Z order. The higher the Z order, the later it will be drawn. Note: negative Z order will be drawn before the parent, and positive Z order will be drawn after the parent.
  • If different parents, then the Z order of the parent decides first, then Z order within each parent.
  • The only way for nodes with different parents to be ordered with each other independently of parent is using VertexZ. (However, I could not get it to work with Cocos2D-X Isometric tile maps across map layers. I ended up removing all the objects (e.g. buildings) on the other layers in runtime and re-inserting them in the same layer as the other sprites as sprites, and then ordering via Z order.

No comments:

Post a Comment