旋转角色Swift游乐场

时间:2018-12-03 19:25:16

标签: ios ipad swift-playground

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

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)

}

此代码用于查找旋转量。

1 个答案:

答案 0 :(得分:0)

我知道了:

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