0

I'm designing new images to be used as SKTextures in an iOS SpriteKit game for many different iPhones. However, I'm noticing a few discrepancies between image features (like height/ width dimensions + resolution on PhotoShop or Preview) and in-game pixels and points.

After reading through material like this stackoverflow question or this Peter Nowell Medium post, I understand that "points" are supposed to be agnostic to screen resolution and that the engine will substitute in different image sizes based on the device (which is why we have the 1x, 2x, 3x image scales provided in Xcode Sprite Atlases).

The device-to-scale mapping is outlined in this reference table and this guide, and it appears as though the iPhone 12 Pro that I'm primarily using for testing (both physically and in the Xcode Simulator) should have 844x390 points with a pixel density of 466 PPI.

enter image description here

This post indicates that PhotoShop follows the same rough standard for points, where a point is 1/72 of an inch and so I used the same point dimensions and PPI in my sprite template:

enter image description here

I also add the sprite to the 3x location in the Xcode image atlas which the iPhone 12 Pro calls for: enter image description here

I then added the image as a SKSpriteNode in my SKScene:

 let testTexture = SKTexture(imageNamed: "testingSprite390x390points_466ppi")
 let testSprite = SKSpriteNode(texture: testTexture)
 testSprite.zPosition = 100
 testSprite.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
 addChild(testSprite)

(Note that in the view controller view.bounds.size == (844.0, 390.0) which agrees with the device-to-scale mapping article)

Unfortunately, after all of this the image sprite which should have just perfectly fit in the screen (as it was 390x390 points and equal ppi) is far too large and doesn't fit on screen:

enter image description here

If I strictly work with pixels (say 1170x1170 for iPhone 12 Pro), then everything fits as expected. Any insight into why points don't seem to be working or advice on whether or not I should abandon them altogether would be really appreciated.

muZero
  • 908
  • 8
  • 21
  • What is the real size of an image that doesn't work in pixes when you export it from bitmap/vector editor, whatever you use? – Whirlwind Feb 23 '22 at 15:34

0 Answers0