【发布时间】:2016-01-03 07:11:49
【问题描述】:
我的应用程序的控件很简单。
- 触摸屏幕左侧调用一项功能。
- 触摸右侧调用第二个函数。 T
- 同时触摸两侧调用第三个函数。
问题是,除非您同时触摸屏幕的右侧和左侧,否则将调用最先触摸的那一侧的函数。我希望能够等待几分之一秒,看看用户是否要在允许调用左侧或右侧功能之前触摸屏幕的两侧。
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in touches {
let location = touch.locationInView(nil)
if location.x < self.size.width / 2 {
touchingLeft = true
}
if location.x > self.size.width / 2 {
touchingRight = true
}
if touchingRight && touchingLeft {
ship.fireMain()
//Wait for 1/10 of a second...
} else if touchingLeft && !touchingRight {
ship.fireLeft()
} else if !touchingLeft && touchingRight {
ship.fireRight()
}
}
}
【问题讨论】:
标签: sprite-kit timestamp touchesbegan