1
SKScene에서 사용자가 화면의 왼쪽 또는 오른쪽을 터치하고 있는지 여부를 감지하려고합니다.화면의 왼쪽과 오른쪽의 터치를 신속하게 감지합니다. SKScene
다음 코드를 함께 넣었지만 터치 한 위치와 상관없이 "오른쪽"만 출력합니다. 작동하는 것 같다
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
let location = touch.location(in: self)
if(location.x > self.frame.size.width/2){
print("Left")
}
else if(location.x < self.frame.size.width/2){
print("Right")
}
}
}
오른쪽 (>)보다 작고 왼쪽 (<)보다 작지 않습니까? –
맞아 .. 어디서나 터치하면 왼쪽으로 출력됩니다. –