ios - Major Bug,在XCAssets 文件夹中创建的Sprite Atlas 不支持批量渲染

标签 ios macos sprite-kit xcode7

我开始在 XCAssets 文件夹中使用新的 Sprite Atlas,而不是将我的 map 集放在项目文件夹中。但是我注意到,当我这样做时,我的节点不再被批量渲染,这导致了大量低效的绘制调用。这完全违背了使用图集的目的!

需要说明的是,这是我用来获取 map 集的代码。

let atlas = SKTextureAtlas(named: "Sprites")

“Sprites”是在 XCAssets 文件夹中创建的 Sprite Atlas。

有没有人有解决方法,或者我是否一直在项目文件夹中制作 Sprite Kit Atlases。

我正在使用 Xcode 7.2 测试版。

我之所以要使用新的 Sprite Kit Atlases 是因为 this问题。

最佳答案

我在输入问题时找到了一种解决方法。您可以从 XCAssets 文件夹内的图像以编程方式创建 SKTextureAtlas,如下所示:

let atlas = SKTextureAtlas(dictionary: ["Head":UIImage(named: "Head")!, "Body":UIImage(named: "Body")!])

这显然只是一种解决方法。希望 Apple 在更高版本的 Sprite Kit 中修复此问题。这是一个非常严重的性能错误,所有开发人员都应该知道。甚至 Apple 的示例项目也使用了新的 Sprite Atlases,因此您认为它们可以进行批量渲染。

更新 1 Apple 的回应:

Thanks for letting us know about this issue. We are currently investigating the cause, and will be incorporating a fix in future iOS updates. In the mean time, there are two workarounds you can apply: 1. Create and use texture atlas in a .atlas folder. 2. Continuing using texture atlas in the asset catalog, but with deployment target set to iOS 8.0.

更新 2 Apple 表示可能已在 iOS 10 中修复。将进行调查。

关于ios - Major Bug,在XCAssets 文件夹中创建的Sprite Atlas 不支持批量渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33976783/

相关文章:

iphone - 停止重新加载从 iPhone 主屏幕启动的网络应用程序

ios - UIPopoverController 中的 UISearchBar 在点击时移动

c++ - 为什么在mac中禁止使用fork without exec?

macos - 如何在 Mac OS X 10.6.8 中通过终端访问 Apache 错误日志?

sprite-kit - CIMotionBlur 在 iOS16 中损坏?

swift - RevMobAds - 测试视频广告未加载?

iOS开发: How am I mismanaging memory in this code?

macos - 在 OS X 中查找已安装应用程序的版本

swift - 如何使用 swift 将 Storyboard与 spriteKit 一起使用

ios - 无法接收 Google 移动添加