4

I am building a spritekit game with 2 screens. Inside the 1st screen the player should pick one Hangar out of 6-7, by horizontal scrolling. When one picked a new SKScene will appear with the actual game play. For scrolling - One Hangar should be centered, while two others are partly shown from the sides.

Can it be done with UIScrollView, on top of SKScene? Or better use sprite nodes for it? I am just not sure about the best way to handle user interface with sprite kit.

Jeff Bauer
  • 13,890
  • 9
  • 51
  • 73
DocForNoc
  • 346
  • 2
  • 13
  • 1
    You can only have one scene running and one SKView (on iOS), there's no split-scene/split-view or dual-scene/dual-view capability if you were looking for that. You'd have to "emulate" the split screen as in Tibor's answer using nodes and sprites and an overlay frame and possibly managing zPosition properly. – CodeSmile Jan 15 '14 at 21:36
  • 1
    Also see this post for some neat UIScrollView usage in Sprite Kit: http://stackoverflow.com/questions/19082251/zooming-and-scrolling-in-spritekit ...and the [example GitHub project](https://github.com/bobmoff/ScrollKit). – Batalia Jan 16 '14 at 15:29
  • Thank you guys, i'll try to go with nodes for now, as timor suggested. – DocForNoc Jan 16 '14 at 15:56

1 Answers1

1

I would implement this by putting the hangars as children of a SKNode. Swiping would move this this SKNode move around with all it's children.

If you wanted the positioning you described; when the swiping has stopped I would use an SKAction to center a the hangar closest to the middle of the screen.

I would do it like this because I think you should only mix in UIKit when necessary because :

  • It is easier to port to OSX
  • You don't have to convert between different types of coordinate systems
Tibor Udvari
  • 2,932
  • 3
  • 23
  • 39