How GlobalZOrder works in cocos2d-js?

993 views Asked by At

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.

1

There are 1 answers

0
Vlad Pazych On BEST ANSWER

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.