参见英文答案 >
1. CGPathMoveToPoint’ is unavailable: Use move(to:transform:) 2. ‘CGPathAddLineToPoint’ is unavailable: Use addLine(to:transform:)1个
我正在更新swift 3的代码.我已经为swift 2中的spritekit对象创建了一个自定义路径.但是,现在我得到一个编译器错误:
我正在更新swift 3的代码.我已经为swift 2中的spritekit对象创建了一个自定义路径.但是,现在我得到一个编译器错误:
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,0 - offsetY) CGPathAddLinetoPoint(path,24 - offsetX,28 - offsetX,40 - offsetY) CGPathAddLinetoPoint(path,18 - offsetX,46 - offsetY) CGPathAddLinetoPoint(path,6 - offsetX,36 - offsetY) CGPathAddLinetoPoint(path,18 - offsetY) path.closeSubpath()
错误是在添加到路径时在第二个参数中传递nil.我尝试传入一个不安全的指针,如下所示:
var tr = CGAffineTransform.identity CGPathMovetoPoint(path,&tr,16 - offsetY) ....
CGPathMovetoPoint is unavailable. Use move(to: transform:)