2013-08-02 94 views
3

有沒有什麼辦法在cocos2d iPhone庫中創建帶圓角的CCLayer類的子類? 也許有些解決方案已經存在? 有什麼建議嗎?帶角落的CCLayer

謝謝。

回答

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

+0

我用你的代碼,除了一些小問題,我不得不編輯,這真是棒極了。非常感謝你。但是因爲我剛剛開始涉足這個東西,所以我不明白,爲什麼我的寬度爲240的圓形圖層看起來像寬度爲960? –