0

If I wanted to create a universal app that worked on all devices using SpriteKit +Swift, what device should I choose to build on?

Currently I am using the iPad Pro 12.9 dimensions

let scene = GameScene(size: CGSize(width: 2048, height: 2732))

and then using

scene.scaleMode = .aspectFit

to apply it to other devices. This makes everything scale well but on the iPhone 11 Pro I have quite big black bars at top and bottom.

Should I choose another device to build on?

Thanks!

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
  • This question gets asked a lot and I remember asking this question too. Its also a good question!. That I've yet to see a really good answer for – hoboBob May 22 '20 at 18:27

1 Answers1

1

Rather than hardcoding the size, set it to match the size of the screen.

let scene = GameScene(size: UIScreen.main.bounds.size)

If you also want to account for the safe area insets (the notch of the iPhone X and newer devices with Face ID), you can do so as explained in this Q&A.

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
  • I had a look at the link you sent. If I set the screen size to the UIScreen.main.bounds.size, how to I draw my graphics? Do I use aspectFit? –  May 20 '20 at 13:56
  • @Questions it depends on what kind of assets you are working with. Vector graphics? Or fixed size images? – Dávid Pásztor May 20 '20 at 13:58
  • Vector graphics. So I was thinking I could design my app on one screen size with one set of images and then use aspectFit to make it fit all other screens? Is that a good approach? –  May 20 '20 at 14:20