我开始在XCAssets文件夹中使用新的Sprite Atlas,而不是在项目文件夹中添加我的地图集。 但是我注意到,当我这样做时,我的节点不再被批处理渲染,导致大量低效的绘制调用。 这完全破坏了使用图集的目的!
要清楚这是我用来获取地图集的代码。
let atlas = SKTextureAtlas(named: "Sprites")“Sprites”是在XCAssets文件夹中创建的Sprite Atlas。
有没有人有解决方法或我坚持在项目文件夹中制作雪碧套件集合。
我正在使用Xcode 7.2测试版。
我之所以想要使用新的Sprite套件集群是因为这个问题。
I started using the new Sprite Atlas in the XCAssets folder instead of having my atlases in the project folder. However I noticed that when I did this my nodes were no longer being batch rendered which resulted in a large number of inefficient draw calls. This completely defeats the purpose of using an atlas!
To be clear this is the code I used to get the atlas.
let atlas = SKTextureAtlas(named: "Sprites")"Sprites" is a Sprite Atlas created in the XCAssets Folder.
Does anyone have a workaround or am I stuck making Sprite Kit Atlases in the project folder.
I'm using Xcode 7.2 beta.
The reason why I want to use the new Sprite Kit Atlases is because of this issue.
最满意答案
我在输入问题时找到了一种解决方法。 您可以通过编程方式从XCAssets文件夹中的图像创建SKTextureAtlas,如下所示:
let atlas = SKTextureAtlas(dictionary: ["Head":UIImage(named: "Head")!, "Body":UIImage(named: "Body")!])这显然只是一种解决方法。 希望Apple在更高版本的Sprite Kit中修复此问题。 这是一个非常严重的性能问题,所有开发人员都应该注意。 即使苹果的示例项目使用新的雪碧图集,所以你认为他们会有批处理渲染的工作。
更新1苹果的回应:
感谢您让我们知道这个问题。 我们目前正在调查原因,并将在未来的iOS更新中加入修复程序。 同时,您可以应用两种解决方法:1.在.atlas文件夹中创建和使用纹理图集。 2.继续在资产目录中使用纹理图集,但部署目标设置为iOS 8.0。
更新2苹果表示可能已经在iOS 10中修复。将进行调查。
I found one workaround as I was typing the question. You can create a SKTextureAtlas programmatically from images inside the XCAssets folder like so:
let atlas = SKTextureAtlas(dictionary: ["Head":UIImage(named: "Head")!, "Body":UIImage(named: "Body")!])This is obviously just a workaround. Hopefully Apple fixes this in later versions of Sprite Kit. This is a pretty serious performance bug that all developers should be aware of. Even Apple's sample project uses the new Sprite Atlases so you think they would have batch rendering working.
Update 1 Response from 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.
Update 2 Apple said may have been fixed in iOS 10. Going to investigate.
更多推荐
发布评论