我做了一个简单的spritekit游戏,当你移动操纵杆时,船会四处移动。操纵杆非常适合移动船只,并且船的角度与操纵杆被按下的角度相匹配。但是,当我想用操纵杆完成180度转弯或任何其他大转弯时,船完全转向毫不拖延然而,在我的游戏中,我想让它变成这样的船,我希望它围成一圈,几乎就像它转过一个看不见的节点一样。我不希望它立即转身,我希望它转过身像真正的船like this.
代码:
//MARK: Handlers begin
moveAnalogStick.beginHandler = { [unowned self] in
guard self.appleNode != nil else {
return
}
}
moveAnalogStick.trackingHandler = { [unowned self] jData in
self.appleNode?.zRotation = jData.angular
guard let aN = self.appleNode else {
return
}
aN.position = CGPoint(x: aN.position.x + (jData.velocity.x * 0.12), y: aN.position.y + (jData.velocity.y * 0.12))
}
moveAnalogStick.stopHandler = { [unowned self] in
guard self.appleNode != nil else {
return
}
}
感谢您的帮助!