主要 Xcode 7 Sprite Kit Atlas 错误 [英] Major Xcode 7 Sprite Kit Atlas Bug

查看:31
本文介绍了主要 Xcode 7 Sprite Kit Atlas 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以今天我决定开始在 El Capitan 和 iOS 9 上测试我的游戏.这是一个大型项目,我已经在业余时间从事了将近 2 年的工作.所以我将我的代码移植到 Swift 2.0,单击运行按钮并祈祷 Apple 没有破坏 Sprite Kit(就像他们过去所做的那样:一个两个三个四个,甚至不要让我开始使用形状节点......).所以我的游戏启动了,你知道什么——我所有的节点都错位了,还有我的动画纹理.还有一些其他小错误,例如未显示抽奖次数,但这些错误很小,希望它们也能得到修复.

So today I decided to begin testing my game on El Capitan and iOS 9. This is a large project that I have been working on in my spare time for almost 2 years now. So I port my code over to Swift 2.0, click the run button and pray that Apple hasn't broke Sprite Kit (as they have in the past: one, two, three, four and don't even get me started on the shape node...). So my game launches, and what do you know — all of my nodes are mis-positioned, as well as my animated textures. Some other small bugs too such as the draw count not showing up but those are small and hopefully they will be fixed as well.

所以我开始调试,最终我发现大部分问题与我的地图集中的节点没有正确定位有关.因此,我只使用一个节点创建了一个示例项目,如下所示.您可以在图片中看到我将节点锚点设置为 (0,0) 并将位置设置为 (0,0).场景的锚点也是 (0,0).我打印出所有这些值以验证它们是否正确.

So I begin debugging and eventually I am able to find that most of the issue is related to the nodes in my atlases not being positioned correctly. So I created a sample project as shown below using just one node. You can see in the picture I set the nodes anchor point to (0,0) and position to (0,0). The scene's anchor point is also (0,0). I printed out all of these values to verify they are correct.

您还可以看到它在编辑器中正确绘制.但是,当我启动游戏时,我得到以下信息:

You can also see that it is drawn correctly in the editor. However when I launch the game I get the following:

可以看到节点绘制不正确.它的位置是(0,0),但它是偏移绘制的.不,我的场景没有缩放,它与视图的大小相匹配并在 ResizeFill 上设置.

You can see that the node is drawn incorrectly. It's position is (0,0) yet it is drawn offset. And no my scene is not scaled, it matches the size of the view and is set on ResizeFill.

我在 El Capitan 和 iOS 9 上都遇到了这个问题.有趣的是,图像包含的透明像素越多,这个问题就越明显.正如您从编辑器屏幕截图中看到的那样,我的图像包含许多透明像素,因为我想清楚地显示错误.如果我使用较少透明的像素,节点的偏移量就会减少.

I get this issue on both El Capitan and iOS 9. What's interesting is that the issue becomes more noticeable the more the image contains transparent pixels. As you can see from the editor screen shot, my image contains many transparent pixels as I wanted to clearly show the bug. If I had used less transparent pixels, the node would have been less offset.

如果我不使用图集,则节点绘制正确,如下所示.但是我显然想使用图集,以便批量渲染我的节点.

If I don't use an atlas then the node is drawn correctly as shown below. However I obviously want to use atlases so that I can batch render my nodes.

我已在 Radar 上提交了此错误.有没有人找到不涉及不使用地图集的解决此问题的方法?

I have filed this bug on Radar. Has anyone found a workaround to this issue that doesn't involve not using atlases?

推荐答案

我在发布问题时找到了解决方法.希望这可以帮助遇到此问题的其他人.并希望 Apple 在最终版本发布之前修复这个主要错误.

I have found a workaround to this as I was posting the question. Hopefully this helps other people who encounter the issue. And hopefully Apple fixes this major bug before the final release.

如果您使用新的 XCAssets 地图集并且将部署目标设置为最新版本,则节点会正确呈现.因此,您所要做的就是将所有图集移至 XCAssets.这会影响 iOS 8/Yosemite 的向后兼容性.

If you use the new XCAssets atlases AND you set the deployment target to the latest version, the node is rendered correctly. So all you have to do is move all of your atlases to the XCAssets. This effects iOS 8/Yosemite backwards compatibility though.

这篇关于主要 Xcode 7 Sprite Kit Atlas 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆