setVertexZ or reorderChild?

setVertexZ or reorderChild?
0.0 0


Hi All,

I need to render several objects and occasionally modify their z ordering.
Should I use setVertexZ() or reorderChild()? Is one more efficient than the other? Also, I noticed in the docs a warning about setVertexZ potentially messing up z parent-child z ordering.



There’re 2 concepts of Z axis in cocos2d.
# Z order. Z order is just the draw order in 2D world, nothing about the Z axis in real 3D world. reorderChild() works only on Z order.
# VertexZ. This one this the real Z axis in 3D world.
To change which one, it depends on your requirement.


I see,
Thanks for the clarification.


Hey I am new to cocos2d-x and please help me to find out the solution of my problem, basically i want to set vertexZ in an Isometric Map so that the my playerSprite hides behind any object like trees or wall or houses etc to give a 3D impression.

To achieve this i tried to implement the code and my playerSprite starts hiding behind an object But i am stuck with one problem like when player come closer or in front of the object then player looks that its standing at very low layer.

I think may be this is the problem with layer… i paste my code so please check it out and give me suggestion.

void gameScene::repositionSprite(float dt)
CCPoint p = player->getPosition();
CCNode **tileMap = getChildByTag;
int newZ = 4 - ;
newZ = max;
int newZ* always give me MAX value 0 and when *reorderChild()* set the player it will always set my player at 0th layer and if manually i update the layer from 0 to 1 then i failed to achieve the output and player don’t hide and move over the object.

i call this above method from the scheduler in the init() method and also set 2Dprojection like this :


if this can’t be implemented then please help me implementing vertexZ

thank you