带有圆角的CCLayer

3
有没有办法在cocos2d iPhone库中创建带圆角的CCLayer子类?也许已经存在一些解决方案了吗?有什么想法吗?
谢谢。
1个回答

3

我在这里得到了原始代码:A-roundedrectangle-ccnode-extension,但在cocos2d 2.0中无法工作。因此做了一些更新。

这是我的圆角图层代码:

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];

下载:CCRoundedRectNode

我用了你的代码,除了一些小问题需要编辑之外,它运行得很好。非常感谢你。但由于我刚开始接触这个领域,我不明白为什么创建宽度为240的圆角层看起来像是宽度为960? - Rodion Baskakov

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接