ios - 带有 UIBezierPath 的 SKShapeNode 未完全填充

标签 ios sprite-kit uibezierpath

我想使用带 UIBezierPath 的 SKShapeNode 绘制圆的填充扇区。 我在大多数情况下工作得很好,但在较小的角度下,形状没有完全填充(在弧线下方有一点缝隙)。像这样:

enter image description here

这是我使用的代码:

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/

相关文章:

ios - InApp-Purchase 有两个不同的价格

ios - Firebase 上传图片和获取 URL 问题

ios - SKNodes 之间的计算距离不会改变,尽管它们在移动

swift - Sprite Kit 中的多点触控手势

ios - uiimageview 底部的曲线 View

ios - 从 ViewController 移除阴影

swift - 如何翻转动画到 CAShapeLayer 上的 UIBezierPath 或 cgPath?

ios - 未调用 UITableView titleForHeaderInSection

iPhone 5 和 5s 问题上的 iOS 通用 Storyboard

ios - SKAction 未在 SKSpriteNode 上运行