I am trying to decide what the best method is to call "level complete-screen" and "game over-screen" in my real-time android 2d game. Currently I am using game-states and only updating my game when its in gamestate==GAMEPLAY, but this sometimes makes resetting some stuff awkward. Another method I have tried is calling a new activity during real-time using context, like this:

public void startMenu() {
    final Context context = this.getContext();
    ((Activity) context).runOnUiThread(new Runnable() {
        public void run() {
            try {
            } catch (InterruptedException e) {
            // Context context = getContext();
            Intent intent = new Intent("nielsen.happy.activities.MENU");
            intent.putExtra("level", level);
            ((Activity) context).startActivity(intent);

This method calls another activity during real-time from a View-class. But it seems a bit clumsy and forced. Just want to know if there is a preferred way to call these screens in real-time games?

  • \$\begingroup\$ Are you looking for best practices? Keeping the code tidy? What is the main goal? How does the game over screen look? \$\endgroup\$
    – AturSams
    Jan 24, 2014 at 10:29
  • \$\begingroup\$ Best practices. Its just a screen where u can see score and choose to restart or go to menu. \$\endgroup\$
    – Green_qaue
    Jan 24, 2014 at 10:42
  • \$\begingroup\$ Could you elaborate on this: "this sometimes makes resetting some stuff awkward". Did you implement a function to reset everything? What problems occurred? It sounds like you are using the new activity where it may be unneeded to overcome an issue with design that cause the complication in resetting stuff. \$\endgroup\$
    – AturSams
    Jan 24, 2014 at 11:13
  • \$\begingroup\$ Im sorry for the poor explenation. At work so had to rush it. Will elaborate later! \$\endgroup\$
    – Green_qaue
    Jan 24, 2014 at 11:53

1 Answer 1


I would need to see a video of the game first to give a specific answer. I personally would implement functionality to pause and reset the game and also to transition to the next stage. In most cases I would not pause the game in stage complete / game over state and simply display a sprite with the relevant text. Then I would either transition to a new level or reset as needed.

I don't think you really need to use this hack / work around and instead ask about the problems that stem from your attempt to pause the game.

Alternatively you could put focus on completing the game and ignore code smell. If the game is fun and it works, it really does not matter how clean and tidy the code is unless you wish to extend it or use code from it in other games.

  • \$\begingroup\$ Good advice, thank you. No experience with releasing games before so just want it to be good! \$\endgroup\$
    – Green_qaue
    Jan 24, 2014 at 11:54

You must log in to answer this question.

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