Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CCLayer with round corners

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.

like image 637
user1021984 Avatar asked Oct 20 '25 15:10

user1021984


1 Answers

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

like image 69
Guru Avatar answered Oct 23 '25 07:10

Guru