2
我有一個簡單的Snake遊戲,頭部繪製一個UIBezier路徑。該部分工作正常:在Spritekit中添加一條路徑EXC_BAD_ACCESS
func addLineToSnakePath(snakeHead: SnakeBodyUnit) {
//add a new CGPoint to array
activeSnakePathPoints.append(CGPoint(x: snakeHead.partX, y: snakeHead.partY))
let index = activeSnakePathPoints.count-1
if (index == 1) {
path.moveToPoint(activeSnakePathPoints[index-1])
}
path.addLineToPoint(activeSnakePathPoints[index])
shapeNode.path = path.CGPath
}
當頭在屏幕上移動時,通過滑動產生路徑。現在我添加一個主體單元以遵循UIBezier路徑,並且出現錯誤的訪問錯誤。
func addBodyPart() {
let followBody = SKAction.followPath(path.CGPath, asOffset: true, orientToPath: false, duration: 1.0)
snakePart.runAction(followBody)
}
崩潰的: 0 SKCFollowPath :: cpp_willStartWithTargetAtTime(SKCNode *,雙)
線程1個EXC_BAD_ACCESS