Friday, 31 May 2013

How to change the z order of a sprite during execution: cocos2d

In cocos2d, the z order of any sprite can be changed programmatically during execution.

Syntax:

    CCSprite * Sprite = [CCSprite spriteWithFile:@"spriteFileName.png"];
    Sprite.position = ccp(250,150);
    [self addChild:Sprite z:1];
        ...
        ...
        ...
    [self reorderChild:Sprite z:5];        // reordering position
                                                        // z  from 1 to 5 means bottom to top 

No comments:

Post a Comment