2014-08-29 101 views
0

我想用Coco2d v3绘制几个实心正方形,其中颜色以编程方式填充并具有边框。在Cocos 2d v3中绘制一个填充矩形

我试过这个帖子的代码,但它不工作。空白是一个transperant 1 * 1像素图像。

-(CCSprite *) rectangleSpriteWithSize:(CGSize)cgsize color:(CCColor*) c 
{ 
CCSprite *sg = [CCSprite spriteWithImageNamed:@"Blank.png"]; 
[sg setTextureRect:CGRectMake(0, 0, cgsize.width, cgsize.height)]; 

[sg setColor:c]; 
return sg; 
} 

回答

1

尝试CCNodeColor:

-(CCNode*) rectangleSpriteWithSize:(CGSize)size color:(CCColor*) c { 
    CCNodeColor *nc = [CCNodeColor nodeWithColor:c width:size.width height:size.height]; 
    return nc; 
} 
+0

但如何绘制边框广场周围 – 2014-08-30 22:04:08