Search code examples
swiftsprite-kittvos

How to setup main menu in tvOS game without breaking "Menu" button default behaviour


I’m having a really hard time getting navigation to work in a game I’m trying to build. I have a main ViewController, that on launch presents a SKScene (MainMenuScene) where I’ve setup a menu of buttons. I’ve also added a TapGestureRecognizer to the MainMenuScene that works nicely so far – the buttons present different SKScene’s and all works as intended.

Now, the problem with using the TapGestureRecognizer is that it breaks the behaviour of the default Menu button on the remote. I’ve read all the SO posts about this and the general consensus is that I should disable the recognizer, but then I cannot get the buttons to work anymore.

I tried overriding the pressesBegan methods in the Scene and while seems to work for when the MainMenuScene is presented the first time, but it doesn’t work anymore if I go to one of the actual game scenes and then back to main menu again. This is probably because I present a new MainMenuScene, not actually referencing the original one I present in the ViewController viewDidLoad method.

Does anyone have a clue how this should actually work?


Solution

  • Finally figured it out – all I had to do, was to remove all the gesture recognizers I had added and it magically works – navigation to Home Screen is still working and all the different scenes are shown each time. Hopefully this helps someone in the future who has the same problem.