当我将path.addEcplipse线更改为path.addCurve时,我有几个节点需要绕一圈旋转,据我所知,代码设置得非常完善,但操作未运行。节点可以完美地执行操作,这里是video
路径的代码:
func createEyePaths() {
eyePath1.move(to: CGPoint(x: 0, y: 0))
eyePath2.move(to: CGPoint(x: 0, y: 0))
eyePath1.addEllipse(in: CGRect(x: 0, y: 0, width: CGFloat(gameScene.frame.height / 1.5), height: CGFloat(gameScene.frame.height / 1.5)))
eyePath2.addEllipse(in: CGRect(x: 0, y: 0, width: CGFloat(gameScene.frame.height / 2), height: CGFloat(gameScene.frame.height / 2)))
eye1Action = SKAction.follow(eyePath1, asOffset: true, orientToPath: true, duration: 2)
eye2Action = SKAction.follow(eyePath2, asOffset: true, orientToPath: true, duration: 4)
viewLine.path = eyePath1
gameScene.addChild(viewLine)
for n in 0...3 {
eyes[n]!.run(eye1Action)
}
for n in 4...7 {
eyes[n]!.run(eye2Action)
}
}
答案 0 :(得分:0)
我仍然不确定为什么这行不通,但使用UIBezierPath(ovalIn:CGRect())作为初始化程序,并使用UIBezierPath.cgPath作为操作的参数似乎可以解决问题