3

Is there any way to create the subclass of CCLayer class with rounded corners in cocos2d iPhone library? Maybe some solutions already exists? Any ideas?

Thank you.

user1021984
  • 621
  • 3
  • 9
  • 25

1 Answers1

3

I got Original Code Here: A-roundedrectangle-ccnode-extension not worked in cocos2d 2.0..So done some updates.

Here is my code for rounded corner layer:

int layer_width = 200, layer_height = 100;

CCRoundedRectNode *shareRectNode = [[[CCRoundedRectNode alloc]
                                     initWithRectSize: CGSizeMake(layer_width, layer_height)] autorelease];

shareRectNode.position = ccp(s.width/2-layer_width/2, s.height/2-layer_height/2);
shareRectNode.fillColor = ccc4f(0.0, 0.0, 0.0, 0.9);
[self addChild: shareRectNode z:3];

Download: CCRoundedRectNode

Guru
  • 21,652
  • 10
  • 63
  • 102
  • I used your code and besides of some small issues I had to edit, it worked great. Thank you very much for that. But since I'm just starting to get into this stuff, I can't understand, why do I get my rounded layer created with width of 240 look like it has width of 960? – Rodion Baskakov Aug 05 '13 at 12:57