Reputation: 1505
So, I'm making a simple game using the iOS game preset, but I'm a bit confused as to the best way of making a main menu. I already have a class for the game scene (it's an SKScene), and most tutorials suggest simply making another similar class for the menu (another SKScene), but when I try to make one I run into a bit of trouble.
The problem is that I don't want to programmatically make the main menu, I'd much rather make it using a storyboard since the drag-and-drop nature of them is much easier to use and shows you instantly what it'll look like in the end, but I can't seem to figure out if it's even possible to do this.
Upvotes: 0
Views: 110
Reputation: 1748
I wanted to do the same thing with my SceneKit game and got a Main Menu created from Interface Builder working pretty smoothly. Here's what you'll need:
This View Controller will be your main menu. Now, to hook it up to your game scene here is what you do:
And that's it! No need to manually create main menus anymore. You can create custom segues by subclassing and you can configure your View Controllers using the various functions that are called during the Segue process (UIStoryboardSegue documentation covers these).
Pro tip: Use @IBInspectable
to allow View Controller properties to be configured from within the Attribute Inspector.
class MyCustomViewController: UIViewController {
@IBInspectable var easy_mode: Bool {
get { isEasyMode }
set { isEasyMode = newValue }
}
var isEasyMode = false
// ...
}
This way you can configure View Controllers from within the Interface Builder by copy-pasting your Game View Controller in your Storyboard, manually setting the "Easy Mode" attribute to "On", and have a different button in your main menu hooked up to this newly configured View Controller using a segue.
Upvotes: 0
Reputation: 1505
I ended up just making the menu using code... except now I have to manually implement text resizing. Surprised nobody knew a solution.
Upvotes: 1