我正在尝试通过触摸来旋转一个玩家。使用touches move函数,我将位置设置为变量,然后调用一个函数。它可以工作,但是角度不正确。位置是全局变量,player是我想要旋转的精灵。它大约偏差15度。
func rotatePlayer(){
let angle = atan2(location!.y - player!.position.y , location!.x - player!.position.x)
player?.zRotation = angle
}
zRotation
为0时,你的玩家面向哪个方向? - 0x141E