Reputation: 1475
I am playing around with iOS 9.2 SpriteKit (using Swift 2.*) and was not sure whether having a button 'panel' on the bottom of the screen should be a nested scene. This feels incorrect to me, but I have not found any docs on the topic of scene nesting. I have attached a screen shot. The orange bit is a mockup from a screen shot and is NOT actual code.
The buttons on the bottom are in a button 'area' (just a term I made up) which is orange. The scene created by the controller is the 'game scene' with the 'starry' background.
So, should the orange panel below be it's own scene or some SKNode subclass with button child nodes, all in the game scene?
Upvotes: 2
Views: 1033
Reputation: 16827
Another alternative is to use UIKit
(UILabels
, UIButtons
, etc) elements as the HUD, with your SKView
being the bottom most layer. This approach is by far easier because you can use auto constraints to map out your HUD without the worry of different devices, but do note that it may have an affect on performance if you have a lot going on.
Upvotes: 1
Reputation: 13665
Nope, you don't want to have nested scenes. Even it is theoretically possible, it will act as a regular node (without some ugly hacking), which is not the purpose of SKScene. In SpriteKit game template you have one SKView and it has only one scene property. So everything is meant for having one scene presented at the time.
What you want is to use SKNode / SKSpriteNode... Usually, people create HUD layer, which is SKNode, and then add elements in it. Bit this is not a must, and you can add these buttons directly to the scene.
Upvotes: 3