我正在尝试平滑地旋转一个始终指向鼠标坐标(Scene.point)的曲柄(self)。
如果我尝试将它旋转整整360度,当zRotation为0度时,它会向后旋转整个360以达到下一个度数而不是继续旋转它应该的方向
self.run(
SKAction.repeatForever (
SKAction.sequence([
SKAction.wait(forDuration: 0.1),
SKAction.run({
let angle = atan2(Scene.point.y - self.position.y , Scene.point.x - self.position.x)
//this resets at if angle passes 0 degrees
let rotate = SKAction.rotate(toAngle: angle - CGFloat(M_PI_2), duration: 0.5)
self.run(rotate)
//this works
//self.zRotation = angle - CGFloat(M_PI_2)
})
])
),
withKey: "New Thread"
)