So I have a game that I made in Swift and I built it and all of its assets for the iPhone 5s. So naturally when built for a 4s or an iPad the game looks distorted and the image views are in the wrong place.
How do I get around this so that the game can work on both the 4/4s and 5/5s? Where do I put the smaller images? I see the 1x and 2x but what exactly does this mean?
Every iPhone since the iPhone 4 in 2010 has a Retina Display. Now we have iPads with Retina Display, too.
You can have an asset named "image1.png" and a higher resolution version of the same asset named "[email protected]". Adding the "@2x" to the end of the file name, iOS knows which asset to use based on the current device's display.
Regarding your "So naturally when built for a 4s or an iPad the game looks distorted and the image views are in the wrong place" comment: what you want to pay attention to here is the actual screen size of the devise you're designing for.
The iPhone 4/4S has a screen resolution of 640 x 960 pixels, while the iPhone 5/5c/5s has a screen resolution of 640 x 1136. The iPad's screen resolution for Retina Display models is 2048 x 1536.
So, I think that your problem is not about creating the assets, but about how you arrange them on screen.
I'd recommend taking a look into an AutoLayout tutorial.
Hope I've shed some light on your problem.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句