I am trying to enable touch on pieces of a sliding tile puzzle so they can each move around the screen.
I want to assign the user's first tap on the screen to
myTouch
[[touches allObjects] objectAtIndex:0]
var tapCen = CGPoint();
var left = CGPoint();
var right = CGPoint();
var top = CGPoint();
var bottom = CGPoint();
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?)
{
let allTouches = event?.allTouches()
let myTouch = allTouches?.first
if myTouch!.view != self.view
{
tapCen = myTouch!.view!.center
}
}
You can try this
let allTouches = event.allTouches()
let myTouch = allTouches?.first
Edit
Swift 3.0
let allTouches = event?.allTouches
let myTouch = allTouches?.first