[英]Custom framework using SpriteKit - asset files not loaded
I created a cocoa touch framework project, which uses SpriteKit and includes image assets. 我创建了一个可可触摸框架项目,该项目使用SpriteKit并包含图像资产。 (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 SKTexture:加载图像资源XXXXX时出错
I am using SKSpriteNode(imageNamed:"XXXXXX"). 我正在使用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 好吧,因为您可以从框架中以UIImage形式获得所需的资产,所以
let image = UIImage(named: "image", in: type(of: self), compatibleWith: nil)
let texture = SKTexture(image: image)
let sprite = SKSpriteNode(texture: texture)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.