我想使用Coco2d v3
绘制几个填充的正方形,其中以编程方式填充颜色并具有边框。
我已经从帖子中尝试过此代码,但是它不起作用。空白是透明的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;
}
最佳答案
尝试CCNodeColor:
-(CCNode*) rectangleSpriteWithSize:(CGSize)size color:(CCColor*) c {
CCNodeColor *nc = [CCNodeColor nodeWithColor:c width:size.width height:size.height];
return nc;
}
关于ios - 在Cocos 2d v3中绘制一个填充的矩形,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25577149/