0
我试图检测用户是否正在触摸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")
}
}
}
谢谢!!一直拉着我的头发。 –
无论锚点如何,您都可以使用frame.midX使其更清洁一些。 “location.x
crashoverride777