By Game Over menu, I mean a menu displayed when you die, with an option to play again.

I have two approaches in mind:

  1. Use OpenGL

    Have some button textures ready. When the character dies, draw them. Listen for events on those textures.

  2. Use a view

    (This is what I'm doing now.) When the user opens the game, I have a basic activity, along with a basic view with a FrameLayout: The root is a GlSurfaceView and there's a menu on top of it (embedded in a LinearLayout). When the user hits "Play", this menu is translated away (using a translate animation) from the screen, leaving only the GlSurfaceView visible, with which the user can interact. I was thinking of implementing something similar when the game ends, but I'm not sure where to start.

I don't particularly like the first approach, since implementing button events in OpenGL seems hard.

How should I approach this?


1 Answer 1


This is a pretty broad question since there are so many approaches so the only thing I can do is tell you what I choose to do in my own games.

I run game states, for example when I'm playing gameState = GAMEPLAY , then when my character dies I change my game state to gameState=gameOverScreen, and using if-statements in my rendering and update methods I check for all the game states, and if (gameState==gameOverScreen) I stop rendering and updating gameplay and bring up my game over menu and change my onTouch method (in update()) to fit the new screen.

This is just one way and Im not sure if its the best way, but there you go.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .