No UIImage(resource:) equivalent for SpriteKit

I love the new UIImage(resource:) initializer that uses the automatically generated symbols for my image assets.

However, there does not appear to be an equivalent in SpriteKit so I am forced to still use SKSpriteNode(imageNamed:)

I am using Xcode 15 Beta 7. Will this be included when Xcode 15 goes into production?

Replies

I don't know if it will be included in SpriteKit, but you can make an extension that uses the SKSpriteNode(texture:) initializer.

extension SKSpriteNode {
    convenience init(resource: ImageResource) {
        self.init(texture: SKTexture(image: UIImage(resource: resource)))
    }
}

and use it like SKSpriteNode(resource: .myImage)