I have a CCSpriteSheet included many sprites who used in different layers. My codes like this:
In the parent layer:
CCSpriteFrameCache *cache = [CCSpriteFrameCache sharedSpriteFrameCache];
[cache addSpriteFramesWithFile:@"Stuff.plist"];
id menuBatchNode = [CCSpriteBatchNode batchNodeWithFile:@"Stuff.png" capacity:120];
[self addChild:menuBatchNode z:0 tag:1];
... ...
MyLayer *childLayer = [MyLayer node]; // MyLayer derived from CCLayer
[self childLayer z:1 tag:2];
In MyLayer :
NSString *frameName = [NSString stringWithString:@"Stuff_child.png"];
CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:frameName];
... ...
id menuBatchNode = [self.parent getChildByTag:1];
[menuBatchNode addChild:sprite z:0 tag:1];
It works, but the sprite of MyLayer cannot be displayed.
If I replace
[menuBatchNode addChild:sprite z:0 tag:1];
with
[self addChild:sprite z:0 tag:1];
The sprite will display. What's wrong with these codes? Can you help me.