Hardware specific atlas with Sprite Kit is blown up on iPad

拜拜、爱过 提交于 2019-12-11 13:48:35

问题


Watching talk 503 "Designing Games with Sprite Kit" from WWDC 2013, they say that one of the benefits of texture atlases is that you only need to drop a folder to XCode and it generate hardware specific atlases for different devices (OSX, iPhone, iPhone Retina, iPad...)

Is that correct?

I'm dropping a folder with a frames for a sprite animation and though it appears the same size on iPad 2 and iPad retina, its size is twice the correct size, and, of course, in the iPad retina the image is pixelated.

What am I doing wrong?


回答1:


Short answer:
Append a @2x suffix to each of your retina pngs inside your .atlas folder (example: heroimage@2x.png) - these will be then displayed correctly on Retina devices. This enables the retina display to calculate the ratio of pixels to points correctly (otherwise they'll appear to be double their size on Retina).
Files with the same name, but without the @2x suffix, will be the non-retina counterpart.

A slightly more complex answer:
if you need to differentiate among more devices, iPhones and iPads, you can use the @2x~ipad suffix and @2x~iphone for the Retina iPad and iPhone, respectively. However, there have been reports of bugs here.

What was meant at WWDC is probably the fact that if you place images for different devices (with different suffixes) in your texture atlas, then the generated collective atlas images are indeed separate for each device. As it says in the iOS Developer Library:

Images for the same device are kept together—for example, all iPhone images are in one file (~iphone.1.png), and all iPad images are in another file (-ipad.1.png).



来源:https://stackoverflow.com/questions/21389481/hardware-specific-atlas-with-sprite-kit-is-blown-up-on-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!