使用 SKShapeNode 在 swift sprite kit WITHOUT 中绘制圆圈的最佳方法是什么? ?问题是 SKShapeNode(circleOfRadius: 100) 似乎不适用于 iOS 7。
这是 iOS 7.1 错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[SKShapeNode shapeNodeWithCircleOfRadius:]: unrecognized selector sent to class
需要的功能:
- 圆需要像 Sprite 一样使用
- 圆圈也需要用作 SKCropNode 的掩码
- 能够使用 SKAction 调整/缩放圆
提前感谢您的任何建议。
最佳答案
记录在案here circleOfRadius 仅适用于 iOS 8.0 及更高版本。 但是您可以使用 SKShapeNode(适用于 iOS 7.0 及更高版本)并将 UIBezierPath(ovalInRect:) 设置为 path属性(适用于 iOS 7.0 及更高版本)如下:
let myShape = SKShapeNode()
myShape.path = UIBezierPath(ovalInRect: CGRectMake(0, 0, 100, 100)).CGPath
myShape.position = CGPointMake(view.scene!.frame.midX-50, view.scene!.frame.midY-50)
myShape.fillColor = UIColor.redColor()
myShape.strokeColor = UIColor.blueColor()
myShape.lineWidth = 10
self.addChild(myShape)
关于ios - 在不使用 SKShapeNode(IOS 7 兼容)的情况下在 swift sprite 工具包中绘制圆圈的最佳方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30316161/