Saving inside userData h2>
You can save the name of the image that you used to create the sprite inside the userData property.
let imageName = "Mario Bros" let texture = SKTexture(imageNamed: imageName) let sprite = SKSpriteNode(texture: texture) sprite.userData = ["imageName" : imageName]
Now, using the sprite, you can get the name of the image that you used originally
if let imageName = sprite.userData?["imageName"] as? String { print(imageName)
source share