Game states vs calling new activities

| | August 18, 2015

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?

One Response to “Game states vs calling new activities”

  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.

Leave a Reply