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

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

问题描述

所以今天我决定开始在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图集 AND ,则将部署目标设置为最新版本,节点正确呈现。因此,您所要做的就是将所有地图集移至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 Bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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