This question is using cocos2d with xcode, but i think general objective c guys can handle it.
I have a class which is a CCLayer and i want to return it as a layer to my main class and show it in there(and all actions happens in that layer class) .
so the “other” class is :
CCSprite *r;
-(id)set
{
r=[CCSprite spriteWithFile:@"c5.png"];
r.position=ccp(50,50);
[self addChild:r z:3];
return self;
}
and from main class i call it with :
recieverCircleLayer *r=[recieverCircleLayer alloc] ;
[self addChild:[r set ]];
so nothing is happen and i dont see that sprite from the other class on screen.
what am i missing ?
thanks .
Your second code snippet should be:
You forgot the
initinalloc-init. Regardless of whether or not that completely solves your problem, it’s definitely a step in the right direction. 😉Also, class names should start with an uppercase letter and be camel cased all the way through. For example,
RecieverCircleLayer.