5
我更新了迅速3.代码我已经创建了我的spritekit对象,在迅速2.工作然而自定义路径,现在我得到一个编译错误:CGPath不是在斯威夫特工作3
Nil is not compatible with expected argument type 'Unsafe Pointer CGAffineTransform'
let offsetX = player.size.width * player.anchorPoint.x
let offsetY = player.size.height * player.anchorPoint.y
let path = CGMutablePath()
CGPathMoveToPoint(path, nil, 10 - offsetX, 16 - offsetY)
CGPathAddLineToPoint(path, nil, 10 - offsetX, 0 - offsetY)
CGPathAddLineToPoint(path, nil, 24 - offsetX, 0 - offsetY)
CGPathAddLineToPoint(path, nil, 24 - offsetX, 16 - offsetY)
CGPathAddLineToPoint(path, nil, 24 - offsetX, 16 - offsetY)
CGPathAddLineToPoint(path, nil, 28 - offsetX, 40 - offsetY)
CGPathAddLineToPoint(path, nil, 18 - offsetX, 46 - offsetY)
CGPathAddLineToPoint(path, nil, 6 - offsetX, 36 - offsetY)
CGPathAddLineToPoint(path, nil, 6 - offsetX, 18 - offsetY)
path.closeSubpath()
错误是在添加到路径时在第二个参数中传递nil。我试图在不安全的指针传递像这样:
var tr = CGAffineTransform.identity
CGPathMoveToPoint(path, &tr, 10 - offsetX, 16 - offsetY)
....
但随后得到了另一个奇怪的错误。
CGPathMoveToPoint is unavailable. Use move(to: transform:)
但是,没有参数名称的移动函数。然而,有一个举措(toParent:)。
谢谢!没有想过检查成员函数的变量。 – patrickd