1

If the default anchor point for an SKScene is (0,0) then does that make the scene stick its top left corner to the top left corner of the device's screen?

Also, if so, what's an easy way to support multiple devices using one scene? For example the default scene size (1024, 768) just fits a landscape iPad such that if I put a node at (0,0) in the scene it appears at the bottom left corner. How do developers usually get around this?

Edit 1

I tried setting the scale mode of the scene to .ResizeFill in didMoveToView():

let screenWidth = UIScreen.mainScreen().bounds.width
let screenHeight = UIScreen.mainScreen().bounds.height

print("Screen size: (\(screenWidth), \(screenHeight))")
print()
print("Scene size before setting scaling: (\(self.frame.width), \(self.frame.height))")
print()

self.scaleMode = .ResizeFill
print("Scene size after setting scaling: (\(self.frame.width), \(self.frame.height))")

This prints out:

Screen size: (667.0, 375.0)
()
Scene size before setting scaling: (1024.0, 768.0)
()
Scene size after setting scaling: (1024.0, 768.0)
Youssef Moawad
  • 2,846
  • 5
  • 28
  • 50
  • Have a look at http://stackoverflow.com/questions/22025967/spritekit-support-multiple-device-orientations – Muhammad Awais Jul 23 '15 at 04:36
  • 1
    Have a look here as well http://stackoverflow.com/q/25205882/2158465 – Epic Byte Jul 23 '15 at 04:51
  • @EpicByte I tried setting the scale mode of the scene as suggested in that thread. Please check my question again. – Youssef Moawad Jul 23 '15 at 06:29
  • 1
    You will need to return to the run loop before the `scaleMode` change takes effect. You can use `view.frame.size` to set up your scene in `didMoveToView` and then use `self.size` in `update`, `touchesBegan`, etc. – 0x141E Jul 23 '15 at 08:12
  • @0x141E ok, and now how does this tie in with the SpriteKit scene editor in Xcode? For example, if I add nodes to the scene through scene editor (with the default size (1024, 768)) some nodes maybe clipped if I run in on an iPhone. – Youssef Moawad Jul 23 '15 at 14:31
  • 2
    @YoussefSami I always set the scene size to the size of the view. Then I position all of my nodes using screen size rules that way they dynamically adjust to each screen size. – Epic Byte Jul 23 '15 at 17:38

0 Answers0