Updated the Level Select screen to handle touch interactions. It’s now possible to tap on a puzzle image and be taken to that puzzle. I ended up using the userData: NSMutableDictionary
property on the SKNode
to both determine if the node the user tapped represents a puzzle, but also, which puzzle they tapped.
private func nodes(touches: Set<UITouch>) -> [SKNode]? {
for touch in touches {
let location = touch.location(in: currentScene)
nodesTouched = currentScene.nodes(at: location)
return nodesTouched.filter {
guard let _ = $0.userData?[“puzzleName”] else { return false }
return true
}
}
return nil
}