可以使用SKShapeNode绘制在精灵试剂盒形状,但是每个SKShapeNode被限制为一个线颜色(则strokeColor)和一个填充颜色。
但是,您可以创建一个包含两个SKShapeNodes儿童,每一个不同的strokeColors/fillColors定制SKNode子类。
像这样的事情会为绘制一个正方形,用自定义SKNode工作左侧和顶部红色,右侧和底部的绿色:
- (id) init {
if (self = [super init]) {
SKShapeNode* topLeft = [SKShapeNode node];
UIBezierPath* topLeftBezierPath = [[UIBezierPath alloc] init];
[topLeftBezierPath moveToPoint:CGPointMake(0.0, 0.0)];
[topLeftBezierPath addLineToPoint:CGPointMake(0.0, 100.0)];
[topLeftBezierPath addLineToPoint:CGPointMake(100.0, 100.0)];
topLeft.path = topLeftBezierPath.CGPath;
topLeft.lineWidth = 10.0;
topLeft.strokeColor = [UIColor redColor];
topLeft.antialiased = NO;
[self addChild:topLeft];
SKShapeNode* bottomRight = [SKShapeNode node];
UIBezierPath* bottomRightBezierPath = [[UIBezierPath alloc] init];
[bottomRightBezierPath moveToPoint:CGPointMake(0.0, 0.0)];
[bottomRightBezierPath addLineToPoint:CGPointMake(100.0, 0.0)];
[bottomRightBezierPath addLineToPoint:CGPointMake(100.0, 100.0)];
bottomRight.path = bottomRightBezierPath.CGPath;
bottomRight.lineWidth = 10.0;
bottomRight.strokeColor = [UIColor greenColor];
bottomRight.antialiased = NO;
[self addChild:bottomRight];
}
return self;
}
正如我说,图纸将充满两种颜色。我如何填写行。这必须是矩形或其他的一次。我承认这是制作绘图的方法,但我只是问我该如何填充它? – Programmer
我不知道你的意思。你能上传你想要的样子吗? – Greg
我已在此发布图片样本。 [链接](http://postimg.org/image/je24gs8yv/) – Programmer