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