SpriteKit PPI

Hi,

I’m looking for a way to keep some custom buttons in SpriteKit the same physical size (inches) accross iOS devices (or only slightly vary their size so they’re not humongous on large screens).

How do I get PPI in Swift? (cannot be library code which doesn’t compile in Swift Playgrounds).

I will use PPI for determining total screen size which I will use to determine how to adjust the button sizes while also respecting some physical desirable dimensions for the buttons.

I'm only asking for handheld (same distance from eyes to screen) use, so I don't care about Apple TV (longer distance).

Answered by Oxygens in 795589022

@Graphics and Games Engineer Thank you, I anticipated your answer and I fully understand that recommendation.

That said, is there a way to get PPI? (not considering Vision OS yet, but a virtual/fake PPI is good enough for compatibility, and would be desired in this case).

The Human Interface Guidelines recommend using a consistent point size for UI elements regardless of the pixel density of the display.

Accepted Answer

@Graphics and Games Engineer Thank you, I anticipated your answer and I fully understand that recommendation.

That said, is there a way to get PPI? (not considering Vision OS yet, but a virtual/fake PPI is good enough for compatibility, and would be desired in this case).

SpriteKit PPI
 
 
Q