Making a portrait only game using SpriteKit and putting my image assets into Images.xcassets
. This is for iPhone, so my image assets are setup like so:
1x, 2x, Retina 4 2x, 3x
For example, under one image asset, a 2x, I have a 640x640 png, this fits fine on iPhone 4/4s, 5/5s but on 6 (which also scales @ 2x) it doesn't, because the 6 has a slightly wider screen @ 750px (or 375 points). So I came-up with the following formula which I can pass into [mySprite setScale:]
for each and every sprite I add to my scene.
CGFloat scale = screenPointWidth / (screenScale * 160)
Where screenPointWidth = [[UIScreen mainScreen] bounds].size.width
and screenScale = [[UIScreen mainScreen] scale]
. 160
refers to a base 1x pixel width value (or 320/2
). This returns a scale multiplayer.
With this multiplayer applied my 640x640 image scales and fits perfectly on a 750 wide screen.
My questions: is there a better way to do this, or am I doing it correct? Is there a universal scaling setting I should be using instead, or should I just scale each and every sprite and sprite position based on my formula? Or, should I not be using Image.xcassets
and instead create individual .atlas' for specific screen resolutions? Should I be concerned about upsampling and downsampling, or is that handled auto-magically by the iPhone 6/6+ itself?
Ref: http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions