0

When creating my game in spriteKit I used the game size 1080x1920. Now however If I am to run it on Ipad it looks bizarre.ipad display Is there an easy fix? I am simply worried that my app will get rejected. Thank you in advance?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
joshLor
  • 1,034
  • 1
  • 12
  • 27
  • 1
    Do you want native support for the iPad or do you want an iPhone-only app to run on the iPad in compatibility mode (as it currently is)? If the former, make your app Universal. If the latter, you must support 3.5" iPhones for it to work properly on iPads. – rmaddy Apr 03 '17 at 01:43
  • @rmaddy Whichever is easier – joshLor Apr 03 '17 at 01:48
  • @rmaddy how can I do it – joshLor Apr 03 '17 at 02:27

3 Answers3

5

Its quite a commonly asked question.

What we usually do in SpriteKt is to give the SKScene a fixed size and let SpriteKit do the scaling for you on different devices.

So basically we have 2 ways to do it correctly

1) Set scene size to iPad (e.g 1024x768 -landscape, 768x1024 - portrait). This was the default setting in Xcode 7.

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

Examples of games that show more on iPads / crop on iPhones:

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, 1334*750-Landscape). This setting will crop your game on iPads.

Examples of games that show less on iPads:

Lumino City, Robot Unicorn Attack

Choosing between those 2 options is up to you and depends what game you are making.

Regardless of scene size scale mode is usually best left at .aspectFill or .aspectFit, again depending on what you prefer and need (e.g cropping with aspectFill or black bars with aspectFit)

You would use the Universal asset slot and/or device specific images. This way you will have a consistent experience on all devices

Spritekit scale full game to iPad

How to make SKScene have fixed width?

Hope this helps

crashoverride777
  • 10,581
  • 2
  • 32
  • 56
4

When you present the scene's you also set the aspect ratio.

example :

if let scene = SKScene(fileNamed: "GameScene") {
    // Set the scale mode to scale to fit the window
    scene.scaleMode = .aspectFill

    // Present the scene
    view.presentScene(scene)
}

There are 4 different aspect radios you can set

  • aspectFit
  • aspectFill
  • fill
  • resizeFill

You can find out about the 4 different types here in the apple documents.

It looks to me that you currently have it set to aspectFill but you would be better off using aspectFit. This will create a black bar on the top and bottom on some devices but it will keep the aspect ratio the same.

If you want it to look good on all devices(no black bar) you would need to check which device it is running on then update the size and position of your sprites accordingly.

Luke Chase
  • 322
  • 1
  • 18
  • I have the exact same swift code as above. And it does **not** work. Currently I am messing with NotificationCenter.default.addObserver(self, selector: #selector(isRotated), name: UIDevice.orientationDidChangeNotification, object: nil). No luck yet. Again, for me, your code above does **not** work –  Dec 19 '22 at 23:44
1

Whenever scenes are hard coded, (not made within the editor) using .resizeFill will ensure that the width AND height of the scene ALWAYS conform to the view. So your game will scale correctly on any device. For scenes that are made within the editor, this is not the case.

Personally, I hardcoded all the levels in my game "Astro Path" (it's on the app store for reference) and used .resizeFill so it would scale correctly on any device without any cropping or black bars. (who wants that stuff yuck) For my title screens, I used: .aspectFill on iPhone .fill on iPad because they were designed within the editor. I checked for the current device using: if UIDevice.current.userInterfaceIdiom == .pad { do w/e }

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 06 '22 at 12:33