如何使 Sprite Kit 以正确的尺寸显示来自 atlas 的@2x 图像? [英] How to make Sprite Kit display @2x images from atlas at correct size?

查看:15
本文介绍了如何使 Sprite Kit 以正确的尺寸显示来自 atlas 的@2x 图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当一个项目只有 @2x 图像,因为它只针对视网膜显示设备,atlas Sprite Kit atlas 的比例错误,因为 RGBA8888_COMPRESSED 设置与 PVR 纹理一起使用.RGBA8888_PNG(默认)有时可以正常工作.

When a project only has @2x images because it only targets retina display devices, atlas Sprite Kit atlas gets the scale wrong with the RGBA8888_COMPRESSED setting to use with PVR textures. RGBA8888_PNG (the default) sometimes works ok.

在切换到 atlas 之前,我将所有 @2x 图像放在一个组中并加载它们:

Before switching to atlas, I had all @2x images in a group and loaded them with:

sprite = [SKSpriteNode spriteNodeWithImageNamed:@"theImage.png"];

没问题.正确的大小.

现在使用 atlas 和 RGBA8888_COMPRESSED,我得到了 SKTexture 并且图像太大了.完全相同的节点和配置.仅使用来自 atlas 的 SKTexture.

Now with atlas and RGBA8888_COMPRESSED, I get the SKTexture and the image is way too large. Exact same nodes and configuration. Only using SKTexture from atlas instead.

为什么会这样?

推荐答案

atlas 图像应该有@2x 后缀,而不是其中包含的文件.

The atlas image should have the @2x suffix but not the files contained in it.

不起作用:

atlas.png contains theImage@2x.png

正确用法:

atlas@2x.png contains theImage.png

我什至不确定 Sprite Kit 一开始就支持 PVR 纹理.也许尝试确认您的设置适用于 PNG,然后导出为 PVR 并尝试.

I'm not even sure Sprite Kit supports PVR textures to begin with. Perhaps try confirming that your setup works with PNG and then export as PVR and try that.

当你这样做时,一定要清理你的项目(Xcode:Project -> Clean)并从设备/模拟器中删除应用程序(这一步很关键!)否则捆绑包仍然会包含 PNG atlas 图像,而你可能会误以为 PVR 可以工作,因为如果您不删除它并清理您的构建,Sprite Kit 实际上可能会加载仍然存在于包中的 PNG 图集.

When you do that, be sure to clean your project (Xcode: Project -> Clean) and remove the app from the device/simulator (this step is crucial!) otherwise the bundle will still contain the PNG atlas image and you may be fooled into thinking that PVR works because Sprite Kit may actually load the PNG atlas that still exists in the bundle if you don't remove it and clean your build.

这篇关于如何使 Sprite Kit 以正确的尺寸显示来自 atlas 的@2x 图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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