PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, September 29, 2022

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

 September 29, 2022     sprite-kit, swift, tvos     No comments   

Issue

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.



Answered By - margusholland
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing