Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My class X is interited from CCLayer.

@interface X : CCLayer

Then in X, I added an instance variable of type CAShapeLayer.

CAShapeLayer *_Circle

I drew the Circle using UIBezierPath. Now if I try to add _circle to self, it gives me error:

[self addChild:_Circle];

[CAShapeLayer tag]: unrecognized selector sent to instance 0x916f7f0 * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CAShapeLayer tag]: unrecognized.

I also tried typecasting _Circle to (CCNode*) or (CCSprite*) but nothing helped.

Any suggestions?

share|improve this question
CAShapeLayer is a class. Try [_Circle tag];. – ott-- Jul 15 '13 at 9:27
No, I am not adding [CAShapeLayer tag] myself. It is coming as a run time exception. My statement is [self addChild:_Circle]; The problem is addChild expects CCSprite or CCNode object but CAShapeLayer isn't that. I am not sure how CAShapeLayer can be used inside cocos2d scenes. – ganesh Jul 16 '13 at 0:16
Is that @interface X : CCLayer a typo? (CALayer?). And isn't it the other way round, first you create a layer and a sublayer, then you draw a spline between them? See… – ott-- Jul 16 '13 at 9:01
CCLayer is a class for layer drawing in COCOS2d. It's not native class. I saw few people suggesting to use CALayer in COCOS2d to animate primitive shapes like circle in my case. I want to programmatically draw a circle and then animate it's drawing on screen. Basically only part of circle will be drawn based on some input value like 60% or 80% and draw should be animated. I have implemented it in CALayer individually but not able to integrate with COCOS2d layers or sceens. – ganesh Jul 17 '13 at 20:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.