我尝试创建NSArray
UnsafeMutablePointer<CGPoint>
,以传递给SKSpriteNode
splinePoints。这个问题非常类似于:Swift SKShapeNode shapeWithSplinePoints
我问它,因为那个帖子的答案似乎不起作用。根据其中一个答案,我需要:
{p>NSArray
其中CGPoint
包含在NSValue
个实例中
虽然如何做到这一点?
我试过这个(这里建议How to create UnsafeMutablePointer<CGPoint> Object in swift)
var shapePoints = [CGPoint]()
// populate with points...
let p = withUnsafeMutablePointer(&shapePoints) { $0 }
let node = SKShapeNode(splinePoints: p, count: shapePoints.count)
此解决方案似乎很接近,但它适用于单个CGPoint
,而不是CGPoint
的数组,因此会抛出此错误:{{1} } UnsafeMutablePointer的百分比抑制率CGPoint] GT; Cannot convert value of type
提前致谢。