func touchesBegan(touches: NSSet, withEvents event:UIEvent) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
player.position.x = location.x
}
}
it gives me this following error
Type of expression is ambiguous without more context
>Solution :
This looks like Swift 2 code. The current signature is
func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
let location = touch.locationInNode(self)
player.position.x = location.x
}
}
And if we are talking about Swift 2 then cast NSSet to native Set and it’s certainly withEvent (singular)
func touchesBegan(touches: NSSet, withEvent event:UIEvent) {
for touch in touches as Set<UITouch> {