Odrakir
Odrakir

Reputation: 4254

Hardware specific atlas with Sprite Kit is blown up on iPad

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?

Upvotes: 1

Views: 631

Answers (1)

Batalia
Batalia

Reputation: 2435

Short answer:
Append a @2x suffix to each of your retina pngs inside your .atlas folder (example: [email protected]) - 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).

Upvotes: 2

Related Questions