Question

Imagine a pack of cards seen from above (this is a metaphor, not the real thing). What I do currently is adding cards on top of another to my layer using addChild. This is one of the rules of drawing order in Cocos2d:

Where nodes have the same parent and same zOrder: nodes are drawn in the order they were added as child

What I want to do is to replace a card with another, without changing its drawing order, and without using the z property (basically, I want to insert children between others).

How do I do?

Was it helpful?

Solution

There's no way. You will need to use z-order. Is the only way to cocos2d know the order of drawings.

But, Why the reason to don't use z-order? It's purpose is only and exactly to define drawing order. If you are using it to identify your sprites, use tag property instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top