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?

  • \$\begingroup\$ CAShapeLayer is a class. Try [_Circle tag];. \$\endgroup\$ – ott-- Jul 15 '13 at 9:27
  • \$\begingroup\$ 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. \$\endgroup\$ – ganesh Jul 16 '13 at 0:16
  • \$\begingroup\$ 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 developer.apple.com/library/mac/#documentation/GraphicsImaging/… \$\endgroup\$ – ott-- Jul 16 '13 at 9:01
  • \$\begingroup\$ 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. \$\endgroup\$ – ganesh Jul 17 '13 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.