1
\$\begingroup\$

Currently my game has an Activity for the splash screen then it starts the main class activity then it starts a menu activity then from the menu there is an activity for each option (only two at the moment), Start and About.

Splash --> Main --> Menu --> (Start, About)

The start then sets a Content View for my game to draw to the screen.

What additional parts to a game should have or require an activity and what parts that I may or may not have don't need to be an Activity.


Activity:

An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View)


Since we know what an Activity is, now I am just looking for places that it would be used in a game?

UPDATE

We have a great explanation of the game architecture in Android. This diagram is awesome!

enter image description here

\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

Use a single activity. Have a look at the basic game architecture here: http://www.thegamecoder.com/blog/?p=46

Implement your menus inside the MainView class in the link.

\$\endgroup\$
2
  • \$\begingroup\$ What other things could you want to do with a game in Android that would require more activities? Anything? \$\endgroup\$
    – KRB
    Sep 14, 2011 at 18:07
  • \$\begingroup\$ I can't think of anything. I'd handle things like web requests with an asynchronous thread of some sort. \$\endgroup\$
    – ApoorvaJ
    Sep 15, 2011 at 13:14
2
\$\begingroup\$

Have a look at Replica Island. It's written by one of the Google engineers. They use different activities for everything. But I think using one activity is way easier! Other games and some of the available game engines do it that way. The downside is that you have to implement behaviour like button presses etc. yourself.

\$\endgroup\$
1
  • \$\begingroup\$ I was wondering about this myself, they use multi-threading too right? one for game logic /sound and one for graphics if I remember correctly. \$\endgroup\$
    – mal
    Feb 24, 2012 at 14:01

You must log in to answer this question.

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