Hi,
I'm getting an application crash and don't know why.
I've got an CCLayer Subclass with a CCLabel iVar.
I initialize the CCLabel in the init method and add the CCLabel
to the CCLayer instance in the "onEnter" method.
The application crashes by calling "return [self addChild:child z:child.zOrder tag:child.tag];"
in the "addChild" Method.
Why could this happen?
The code:
- (id)init {
if (self == [super init]) {
self.spriteSheet = [CCSpriteSheet spriteSheetWithTexture:[[CCTextureCache sharedTextureCache] addImage:SPRITESHEET_IMAGE_FILENAME]];
[self addChild:self.spriteSheet];
self.threeChar = [CCLabel labelWithString:@"3" fontName:FONT_NAME fontSize:30];
self.threeChar.tag = 103;
return self;
}
- (void)onEnter {
[super onEnter];
[self schedule:@selector(showThree:) interval:0.0];
}
- (void)showThree:(id)sender {
[self addChild:self.threeChar];
[self.threeChar runAction:[CCFadeOut actionWithDuration:1.0f]];
[self removeChildByTag:103 cleanup:YES];
}