Search code examples
sprite-kitscreenxcode7sizing

Screen sizes in Xcode 7 the using SpriteKit


I am relatively new to sprite kit and have been attempting to create my first basic game. All physics and other basics seem ok, but for some reason whenever I build and run the screen dimensions are off (looks like default is 1024×768)?

Pretty sure I'm missing something fundamental here but it doesn't seem immediately obvious on how to adapt the screen to any size iPhone screen (this is my ultimate goal).

My question is whether this is actually just a setting issue or is it necessary to implement code?

Thanks in advance and have a great day!:)


Solution

  • To answer the first part, you can easily change the size of your scene.

    If you take the default GameScene, click out of the scene and look at the Attributes Inspector. You will see the default size of 1024,768. Personally if landscape I tend to work with an iPhone 5 design resolution of 568,320.

    Regarding multiple devices, SpriteKit works pretty well out the box. You should look at the documentation regarding scaleMode, take a look in the GameViewController.swift. .AspectFit worked really well, nearly pefect across all devices apart from a little letterboxing on iPad. However, for the amount of effort put in, more than good enough.

    On a side note, I've found the following iPhone Resolution Guide resource useful in the past.