I created a cocoa touch framework project, which uses SpriteKit and includes image assets. (It's a framework because the idea is to create a mini game that I can add to different apps). I am testing it with a sample project that uses this framework.
My problem is at runtime - when I create a sprite with an image I get an error:
SKTexture: Error loading image resource XXXXX
I am using SKSpriteNode(imageNamed:"XXXXXX"). the images are in the bundle of the framework in a folder. I tried also putting them in an asset catalog. nothing works.
Any ideas what the problem is?
Well since you can get the desired asset from the framework as a UIImage, couldn't you just
let image = UIImage(named: "image", in: type(of: self), compatibleWith: nil)
let texture = SKTexture(image: image)
let sprite = SKSpriteNode(texture: texture)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.