Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spritekit scale full game to iPad

So I'm developing a game on Xcode using Spritekit, for the iPhone. And it looks all the same and great on all iPhone devices, by using the node.setScale() method. Now I want to make it Universal and runnable on the iPad as well. How do I do this easily? Is there some formula for the scale?

What I already tried was this:

if UIDevice.current.userInterfaceIdiom == .pad {
        sscale = frame.size.height / 768
    }else{
        sscale = frame.size.height / 320
    }

And then for every node I make node.setScale(sscale).

This ends up not working because on the iPad Mini it looks different from the iPad Air... i.e node sizes and positions...

Any help?

like image 742
Pedro Cabaco Avatar asked Jan 05 '23 12:01

Pedro Cabaco


1 Answers

You basically have 2 options.

1) Set scene size to 1024X768 (landscape) or 768x1024 (portrait) and use the default .aspectFill for scale mode. This was the default setting in Xcode 7 (iPad resolution).

You than usually just show some extra background at the top/bottom (landscape) or left/right (portrait) on iPads.

Examples of games that show more on iPads:

Altos Adventure, Leos Fortune, Limbo, The Line Zen, Modern Combat 5.

2) Apple changed the default scene size in xCode 8 to iPhone 6/7 (750*1334-Portait, 1337*750-Landscape). This setting will crop your game on iPads.

Chosing between the 2 options is up to you and depends what game you are making. I usually prefer to use option 1 and show more background on iPads.

Regardless of scene size scale mode is usually best left at the default setting of .aspectFill or .aspectFit

To adjust specific things such as labels etc for a device you can do it this way

 if UIDevice.current.userInterfaceIdiom == .pad {
   // adjust some UI for iPads
 }

I would not try to do some random hacks where you manually change scene or node sizes/scales on difference devices, you should let xCode/SpriteKit do it for you.

Hope this helps

like image 107
crashoverride777 Avatar answered Jan 15 '23 22:01

crashoverride777