0

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.

  • I'm not using cocos2d-js, but in cocos2d-x as far as I remember setGlobalZOrder doesn't do anything too. Instead I'm using setLocalZOrder. Everything on default has z order 0. – Makalele Dec 16 '15 at 13:12
  • It's weird. For now I solved it with sorting layers (just usual layers with localZOrder) and containers that manage behaviour of their 'fake' children, that in fact are children of one of sorting layers. – Vlad Pazych Dec 16 '15 at 15:21

1 Answers1

0

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.

Community
  • 1
  • 1