Tonight I was working on handling the back button on the Android build. I wanted it to pop up a simple exit-confirmation type of menu. LibGDX provides a nice handler for catching the back button (see the docs and this post on Stack Overflow), and it was pretty easy to pop up the menu. Quitting the game or canceling the menu were both no problem, but I kept having trouble whenever I'd use the "Main Menu" button.
No, this is not the final visual design for the menu. Yes, that button says Robo-Nina. Oops. |
I could get it to take me back to the Main Menu without issue, but the next time I'd hit the back button, the menu wouldn't appear. I spent a good 30 minutes stepping through with the debugger before I figured out my mistake:
When I started the game over, I instantiated a new UI/menu overlay object that controls all the on-screen popups (the Hud object). My back button handler, which I didn't re-instantiate, was holding on to a reference to the old Hud, which wasn't being displayed anywhere. So the old Hud, off in limbo-land, was trying it's hardest to show me a menu, it's too bad I wasn't actually DRAWING the old Hud.
1 comment:
I'm enjoying these updates about the Robo-Ninja development process. When I read about the ramp collision processing, I started working out solutions in my head. (But that's not necessary, you've already solved it!)
In college I was working on an asteroids-style game. I had many ideas to make it more interesting than simply randomly generated space rocks. It was a lot of fun to build, though I never got around to adding many of the features I had in mind.
Having libraries like LibGDX sounds like the way to go. I imagine that if I were to restart my game development I could move it along pretty quickly.
Post a Comment