【发布时间】:2015-07-29 04:02:27
【问题描述】:
我的 touchesBegan 对于发生的每个不同的触摸事件都能正常工作,但我同时触摸两个不同的位置时除外。我总是必须先抬起一根手指,然后才能放下另一根手指。有没有办法让touchesBegan(并希望touchesMoved)同时为两个不同的触摸工作?在我的项目中,我有一把剑,如果你点击手柄,它会平移剑,如果你点击刀片,它会旋转剑,但是如果你同时点击两者,剑就会飞过屏幕.
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch in (touches as! Set<UITouch>) {
let location = touch.locationInNode(self)
dx = location.x - Handle.position.x
dy = location.y - Handle.position.y
locationAngle = atan2(dy, dx)
if (HandleTouch.containsPoint(location)){
touchedHandle = true
}
else if (BladeTouch.containsPoint(location)){
touchedBlade = true
}
}
}
【问题讨论】:
标签: xcode swift touch-event touchesbegan