0
\$\begingroup\$

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() {
            thread.setRunning(false);
            try {
                thread.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            // 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?

\$\endgroup\$
  • \$\begingroup\$ Are you looking for best practices? Keeping the code tidy? What is the main goal? How does the game over screen look? \$\endgroup\$ – wolfdawn Jan 24 '14 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 '14 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\$ – wolfdawn Jan 24 '14 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 '14 at 11:53
2
\$\begingroup\$

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.