Welcome to the Treehouse Community
Looking to learn something new?
How do I create a menu?
i can't just add buttons because there is no view on a scene
Stone Preston42,016 Points
if you want to use sprite kit to make your menu you can add SKLabelNodes and use those as buttons. Since SKLabelNode inherits from SKNode it has touchesEnded/began/moved methods. you would need to subclass SKLabelNode and make a specific class for each button and override the touch methods if you wanted to do it that way. Depending on how many buttons you want to have this could get tedious as you would have a bunch of classes for all the different buttons so that they could each have a unique action on button presses.
another way would be to override the touchesEnded/began methods of your scene and then check to see if the touches were within the buttons frame. again depending on the number of buttons this could get tedious as you would have to check the frame of each button in your scene
AGSpriteButton works pretty well. it allows you to add different actions to your button to make it behave more like a UIButton. Ive used it pretty easily to make buttons but i prefer the method below since the hard part about making a menu is the layout and laying out SKLabels and sprites all in code can be annoying sometimes
you could add UIButtons directly to the view controller in storyboard and create actions for those buttons as well too. This way would be a lot easier than using sprite kit and designing a menu using SKLabels is pretty tedious since its all gotta be code. the storyboard would make it a lot easier.
If were making a menu for my game Id probably use storyboard and UIButtons and then setup my spritekit scene inside the button actions and what not. This would also make it easy to implement a navigation controller if you wanted to have multiple menu screens to navigate through etc etc.
yes thank you about the UIButtons way of doing things i wouldn't want my buttons to appear during game play , unless theres away to transition from SKScene on Game view controller to another view controller and vice versa.
alright i will give it a shot . Thanks-
how can i segue from a skscene to another view controller like you said