我想使用带 UIBezierPath 的 SKShapeNode 绘制圆的填充扇区。 我在大多数情况下工作得很好,但在较小的角度下,形状没有完全填充(在弧线下方有一点缝隙)。像这样:
这是我使用的代码:
CGPoint center = CGPointMake(500, 300) ;
UIBezierPath *bezierPath = [UIBezierPath bezierPath];
[bezierPath addArcWithCenter:center radius:400 startAngle:1.825777 endAngle:2.011118 clockwise:YES];
[bezierPath addLineToPoint:center];
[bezierPath closePath];
SKShapeNode *shapeNode = [SKShapeNode shapeNodeWithPath:bezierPath.CGPath];
shapeNode.strokeColor = [UIColor whiteColor];
shapeNode.fillColor = [UIColor whiteColor];
[self addChild:shapeNode];
iPad 和模拟器 (iOS 8.1) 上的结果相同。
我是做错了什么还是有一些限制或错误?
如果无法使用这些 API 更准确地绘制此形状,能否请您建议一些其他方法在 SpriteKit 游戏的上下文中绘制它。
提前谢谢你。
最佳答案
这可能是 SKShapeNode 错误,请参阅 http://sartak.org/2014/03/skshapenode-you-are-dead-to-me.html
一个解决方法是增加 SKShapeNode 的线宽,以填补空白。
shapeNode.lineWidth = 4
您可以使用相同的 bezierPath 对 UIKit 执行相同的操作,并在 drawRect 中对其进行填充和描边。
关于ios - 带有 UIBezierPath 的 SKShapeNode 未完全填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28097416/