zOrder

HI
is there a way to ensure that a certain CClayer (Ball) will always the the top most layer. I have the situation that some CCLayers are being added to the parent to a later point in time and they of course have a higher ZOrder than the CCLayer (Ball) which should be on top.
I am banging my head to find a simple solution

Thanks for any help.

I suppose you could traverse the node and rearrange the layers.

Why not just give your ball a high order to begin with? That way when the layers are added they are behind still

addchild(layer, 0);
addchild(something else, 1);
addchild(ball, 99); // ball is on top

later on:

addchild(something new, 2);
addchild(something new again, 3); // both of these would be behind the ball.

I do this all the time and have hundreds of sprites on my screen and a few different layers and HUDS as well.

Thanks Jason

I tired that but I am using a tile map and the tiles seem to have quite high Z orders. Since I am randomly changing tiles I am having a hard time to ensure that the Ball stays on top of the tiles.