5

In nearly every tutorial for beginner SpriteKit game making I've seen, people delete the GameScene.sks with no real explination.

The reason why building simple non-game apps is so beginner friendly is because of the Storyboard.

Ray uses the GameScene here:

http://www.raywenderlich.com/84341/create-breakout-game-sprite-kit-swift

Is there any reason why NOT to use this tool? Writing out EVERYTHING in code is a little more daunting when you have this tool sitting right here that seems to simplify it a bit.. but I'd rather avoid it if it's better to do so.

Thanks in advance.

Barkley
  • 6,063
  • 3
  • 18
  • 25

1 Answers1

6

It's all personal preference really. I think the reason why people delete it though (at least in my opinion) is due to the following reasons:

  1. You have to specify an initial scene size in the file. Whereas if you create the scene programmatically you can set the size to the view size.
  2. The editor is very limiting. Xcode 7 however greatly expands the editor to include much more such as custom classes.
  3. There were some pretty big bugs/crashes in the initial release of Xcode 6.
  4. When learning Sprite Kit it's good to know how to programmatically do things instead of doing it visually. This is because games often have dynamic gameplay so you will certainly have to do things programmatically (especially when you consider the limitations of the Xcode 6 editor).
  5. Some people (including myself) may use their own custom editor for designing levels etc. Whereas interface builder is standard because it has become very powerful over the years and works perfectly with UIKit.
Epic Byte
  • 33,840
  • 12
  • 45
  • 93
  • Awesome answer, thank you so much! – Barkley Jun 25 '15 at 21:57
  • Is there a workaround that you know of for the first problem you mentioned? I'm super, super new, but I assume what that means is that you'd run into issues on different sized phones? I see everyone using percentages to counter the problem of different sized screens, so if you use the Scenekit is there any real workaround to that? – Barkley Jun 25 '15 at 22:15
  • 1
    @Swiftaccnt Yes, a very easy one. You set your scene scale mode to ResizeFill. Or you can set the size of the scene after it's created. There are so many factors that are involved when it comes to supporting multiple devices. You could scale your scene by using the scaleMode. You could scale your nodes directly instead of scaling the scene. You could take advantage of the larger view size. You could implement scrolling if you have a large game world. I recommend you read through my answer here and all the related links at the bottom. http://stackoverflow.com/a/25256339/2158465 – Epic Byte Jun 25 '15 at 22:27
  • Wow man, you're incredible. I'm looking to just make something super, super simple as my first project and so for something like that it seems like the game scene might be a decent enough starting place based off what you've said. Nothing great for super dynamic anything, but yeah.. Thanks so much for your replies! I'll go check out your link. Have a good one buddy. – Barkley Jun 25 '15 at 22:32
  • @Swiftaccnt What I do in my game is create scaling/positioning rules based on the size of the view and update whenever the scene changes size. This keeps all of my stuff dynamic and works with all devices even when the view is resized (Mac OS X changing the window size, iOS orientation change, iPad Air 2 multi-app). In my case all of my UI follows scaling rules, while my game world simply takes advantage of the larger display to show more of the world content. A little tip is place your nodes in a container node and then scale/position the container. It will make things easier. – Epic Byte Jun 25 '15 at 22:33
  • Yeah, fantastic answer you gave that guy. Definitely some good info there that helps me as well. Thanks. – Barkley Jun 25 '15 at 22:34
  • Yeah that makes a lot of sense and like it'll work beautifully for what I'm looking to do. – Barkley Jun 25 '15 at 22:35
  • @Swiftaccnt And sometimes you just can't scale up. There might be an interface element that looks good in one spot on larger devices, etc. In this case you have no choice but to handle special cases. Good luck with your game! – Epic Byte Jun 25 '15 at 22:36
  • Thanks again man, you went above and beyond :)! – Barkley Jun 25 '15 at 22:39
  • Hey haha, I hate to call you back after you've already spent so much time but I've got one more quick question: So just before I start with this , just making extra , extra sure.. If in my game scene I've got **let scene = GameScene(fileNamed:"GameScene.sks") ** and ** SKSceneScaleMode.AspectFill**, if I put something 50 pixels down from the top with a screen set to the size of a 5s, it's going to convert that 50 px to the appropriate amount for other screen sizes? My entire game is based off of things being spaced out right haha, so just want to make sure I'm on the right track. – Barkley Jun 27 '15 at 18:27
  • @Swiftaccnt That is correct. However it will scale not only the position but the size as well. I would try to stay away from scaling your scene and instead position/size your nodes using some rule. For example, if you want to keep that node in the same relative position on all devices, pick a starting resolution, such as a iPhone 4 (smallest screen) and scale the position up like so: node.position.y = 10 * view.size.height/480.0 this example will scale the y as the height of the view increases so it always looks the same vertically. The reason I prefer this over just scaling the scene is – Epic Byte Jun 27 '15 at 18:38
  • @Swiftaccnt because it lets you scale all of you nodes separately and customize the rules associated with their layout. Of course if your game can get away with it you can try scaling the entire scene, it's just that sometimes your game interface/content is too complex. – Epic Byte Jun 27 '15 at 18:40
  • Awesome. I think I'm all set haha! Thanks so much again. – Barkley Jun 27 '15 at 18:55