Hi there!
I have my Plane class inhereted from CCSprite. It has a weapon that is inhereted from CCNode (cus i don't need to draw weapon, but i need some stuff from CCNode, like rotation, position, parent, etc.). My weapon has no other cocos classes in it.
Also I have created a CCSpriteBatchNode in my game scene from atlas that includes all my game objects sprites.
I try to add my Plane to that BatchNode as a child. There it crashes, cus of a weapon, inhereted from CCNode with log:
"-[Weapon useBatchNode:]: unrecognized selector sent to instance .."
AFAIK BatchNode is trying to add my weapon to itself, and sends [weapon useBatchNode:] to it.
Something goes wrong in cocos, or mb it's my fault?
btw, that's my code:
plane.m
+(id) create
{
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:kAirplane1FrameName];
return [self spriteWithSpriteFrame:frame];
}
-(id) initWithTexture:(CCTexture2D*)texture rect:(CGRect)rect
{
if( ![super initWithTexture:texture rect:rect])
return nil;
...
self.weapon3 = [[Weapon alloc] init];
self.weapon3.position = ccp( 0, weaponOffsetY );
[self addChild:self.weapon3 z:5];
...
return self;
}
weapon.m
-(id) init
{
if ( ![super init] )
return nil;
fireRate = 1;
projectileType = @"Projectile";
projectileSpeed = 100;
return self;
}
P.S. when i'm removing weapon from my plane:
self.weapon3 = nil;
all works fine.