我的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
}
}
}发布于 2015-07-29 12:14:00
确保视图的multipleTouchEnabled属性设置为true,您可以在代码中或使用界面生成器中的“多点触摸”复选框来执行此操作。
https://stackoverflow.com/questions/31691034
复制相似问题