This is the function I am using in my code:
-(id) initFromNormalSprite:(CCNode<CCRGBAProtocol>*)normalSprite
selectedSprite:(CCNode<CCRGBAProtocol>*)selectedSprite
activeSprite:(CCNode<CCRGBAProtocol>*)activeSprite
disabledSprite:(CCNode<CCRGBAProtocol>*)disabledSprite
name:(NSString*)name
target:(id)target selector:(SEL)selector
{ if (( self = [super initFromNormalSprite:normalSprite selectedSprite:selectedSprite disabledSprite:disabledSprite target:target selector:selector])) { self.activeImage = activeSprite; self.name = name;
// TODO, create an addSpriteFrameByName extension
CCSpriteFrameCache* fcache = [CCSpriteFrameCache sharedSpriteFrameCache];
NSString* glowName = @"frames-glow.png";
if([fcache spriteFrameByName: glowName]) {
} else {
CCTexture2D* glowTex = [[CCTexture2D alloc] initWithImage: [UIImage imageNamed:glowName]];
CCSpriteFrame* spriteFrame = [[CCSpriteFrame alloc] initWithTexture:glowTex
rect:CGRectMake(0,0,glowTex.pixelsWide,glowTex.pixelsHigh)];
//offset: ccp(0,0)];
[fcache addSpriteFrame:spriteFrame name:glowName];
[spriteFrame release];
[glowTex release];
}
self.glow = [CCSprite spriteWithSpriteFrameName:glowName];
self.showGlow = true;
}
return self;
}
It's building fine but crashes in simulator with the following:
2010-12-24 23:22:48.417 PanelsExample[8967:207] * Assertion failure in -[NMPanelMenuItem addChild:z:tag:], /Users/aeshverma/Downloads/jashmenn-shapes-panels-bcf4e74/cocos2d/CCNode.m:360 2010-12-24 23:22:48.430 PanelsExample[8967:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'child already added. It can't be added again'
please help me out.
Thanks