0

I want to set the z order of one CCNode but I have been trying this three options and it doesn't working:

myNode.zOrder = 10;

myNode.physicsNode.zOrder = 10;

[myScene reorderChild:myNode z:10];

Also the myNode.physicsNode.zOrder sets de z orders of all CCNodes that are inside the CCPhysicsNode, no matter what Node is myNode.

Thanks for all!

1 Answers1

0

Setting the zOrder property should be enough. Remember that nodes with higher zOrder are drawn in front.

I just tested this successfully:

    CCSprite *sprite1 = [CCSprite spriteWithImageNamed:@"image1.png"];
    sprite1.position = ccp(100, 100);
    [self addChild:sprite1];

    CCSprite *sprite2 = [CCSprite spriteWithImageNamed:@"image2.png"];
    sprite2.position = ccp(110, 110);
    [self addChild:sprite2];

    sprite2.zOrder = -10; // second sprite goes behind
sdabet
  • 18,360
  • 11
  • 89
  • 158
  • That's right, but my problem is not with the visualization. The dificulty is when I drag the sprites. I can put one in front of other one, but when I tried to drag whit: – user3739270 Jun 20 '14 at 17:31
  • That's right, but my problem is not with the visualization. The difficulty is when I drag the sprites. I can put one in front of other one, for example, sprite1 is in z = 2 and sprite2 in z = 1, and with .zOrder I change it to sprite1 in z = 1 and sprite2 in z = 2. But when I try to drag the sprite2, that now is in front of sprite1, I can't, instead of that I drag sprite1 and I have to put it away in order to drag the sprite2, no matter if it is on front. – user3739270 Jun 20 '14 at 17:40