cocos2d-xcocos2d-jsz-ordercocos2d-html5

How GlobalZOrder works in cocos2d-js?


I have nested tree:

self.addChild(red);
self.addChild(green);
green.addChild(blue);

I get this: (Screenshot)

How can I put blue square behind others, without changing my tree to make it look like this: (Screenshot)

setGlobalZOrder(), does nothing:

red.setGlobalZOrder(2);
green.setGlobalZOrder(3);
blue.setGlobalZOrder(1);

Is there any way of doing this?

Thanks.


Solution

  • I got the answer on github:

    The global z order is affecting only for Sprite objects.

    Github issue link

    So it didn't work for me, because I was playing with LayerColor.