Reputation: 791
My touchesBegan works correctly for each distinct touch event that happens, with the exception of when I touch in two separate locations at the same time. I always have to lift up one finger before I can place down another. Is there a way I have can have touchesBegan (and hopefully touchesMoved) work for two different touches simultaneously? In the case of my project, I have a sword, and if you click on the handle it translates the sword, and if you click on the blade it rotates the sword, but if you click on both, the sword flies all over the screen.
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
}
}
}
Upvotes: 1
Views: 795
Reputation: 2782
Make sure that the multipleTouchEnabled
property of your view is set to true
, which you can do in code or with the "Multiple Touch" check box in Interface Builder.
Upvotes: 2