简体   繁体   English

使用SpriteKit的自定义框架-未加载资产文件

[英]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.

相关问题 在SpriteKit项目中使用精灵图集,纹理图集或资产目录 - Using a sprite atlas, texture atlas, or asset catalog in SpriteKit projects SpriteKit正确的资产大小 - SpriteKit correct asset size 自定义框架未加载dyld:库未加载:@rpath / Custom.framework / - Custom framework not loaded dyld: Library not loaded: @rpath/Custom.framework/ 有效的MacOS / iOS框架,用于渲染自定义地图(Spritekit或Raw Metal)? - Effective MacOS/iOS framework for rendering custom maps (Spritekit or raw Metal)? 简单SpriteKit场景中的资产大小问题 - Issue with asset sizing in simple SpriteKit scene SpriteKit自定义节点边界 - SpriteKit Custom Node Boundary Objective-C 错误:dyld:库未加载:@rpath/custom_framework.framework/VT_custom_framework - Objective-C Error : dyld: Library not loaded: @rpath/custom_framework.framework/VT_custom_framework SpriteKit自定义UIScrollView加速 - SpriteKit custom UIScrollView with acceleration 如何将资产包含在框架中? - How to include asset in a framework? iOS 5:使用StoryTable将使用UITableView中加载的资产对象显示在另一个ViewController中 - IOS 5: Using Asset Object loaded in UITableView to display in another ViewController using StoryBoard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM