我还如何从安全区域获取信息?

时间:2019-05-17 20:17:32

标签: swift sprite-kit

我目前正在尝试对游戏进行编程,并希望在我触摸屏幕一侧时让玩家移动。问题是我只能从安全区域内部获得触摸,而不能从外部获得触摸。

override func touchesBegan(_ touches: Set<UITouch>, with event:       UIEvent?) {
     if let touch = touches.first {
        if touch.location(in: view).x > view!.frame.maxX - 100 {
            moveL = false
            moveR = true
        }else if touch.location(in: view).x < view!.frame.minX +
100{
            moveR = false
            moveL = true
        }
    }
}

0 个答案:

没有答案