Hi everyone.
I’m having trouble drawing a label in front of sprites.
It is easy to reproduce. Just open NewRendererTest.cpp (official cpp test source code)
The text is rendered behind the sprites. Shouldn’t it be in front?
Using label->setGlobalZOrder(30) does’t work either (although it does work for the sprites… strange!)
The only way drawing in front is adding to the parent node the last.
But I’d like to alter the z order.
Why doesn’t setLocalZOrder work?
Yes.
I just need a way to reorder the depth of sprites and labels. Not the order in which they are created.
Any approach would be fine. But I haven’t found a way yet.
Could you try this particular test? Just do a simple change and recompile the cpp tests.
Just to know if there’s something less obvious in my setup.
Thank you
I’m not sure why you are stuck on this fact. cpp-tests is just a set of code we use to test the functionality of the engine. Why not create using cocos new and try the code I showed you. You aren’t going to start from cpp-tests. I will try the test you mention though.
Yes, sorry, sortAllChildren was added later while testing.
Anyway, it doesn’t solve the problem.
The reason why I’m using cpp-test is because I’m getting the same problem in my game.
I wanted to find a way to reproduce the issue. This way it is simpler to report and test by others.
As you can see, using depth parameter in addChild doesn’t work, but global Z does work (but it doesn’t for labels…). Could you try if this is the behaviour for you also?