旋转角色Swift Playgrounds



我不知道我在这段代码中做错了什么:

func findDegree() -> Double {
let xValue = directionstick.center.x - 35
let yValue = directionstick.center.y + 20
let newX = xValue*xValue
let newY = yValue*yValue
let hypo = (newX+newY).squareRoot()
return (xValue/hypo)
}

此代码用于查找旋转量。

我发现了:

func findDegree() -> Double {
let xValue = directionstick.center.x - 35
let yValue = directionstick.center.y + 20
let angle = atan2(xValue, yValue)
Return angle
}

最新更新