点击时精灵方向改变?

时间:2017-02-11 12:30:29

标签: ios swift sprite skaction

我试图在touchesBegan时向左移动精灵,然后在下次用户触摸时向右移动。

我已经看到了一些我觉得可以完美运行的代码但是我不太清楚如何定义" isMovingleft"

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    ship.removeAllActions()

    if isMovingleft == true  {
        let left = SKAction.moveBy(x: 500, y: 0, duration: 5)
        ship.run(left)
    }
    else {
        let right = SKAction.moveBy(x: -500, y: -900, duration: 5)
        ship.run(right)
    }
    isMovingleft = !isMovingleft


}

1 个答案:

答案 0 :(得分:1)

endRendering
相关问题