I'm writing a game for Android. My GUI has the following basic screens (i.e. the information and interactions required on each of these would take up the whole display):
- Main menu (let you start a new game, enter settings, see high scores, see about screen)
- Game screen i.e. where the actual game is played.
- Settings screen.
- High scores screen.
- About screen (i.e. credits and a back button)
- Game over screen (arrived at when the game ends)
- Pause screen (pauses game and can access settings)
The following are some example transitions the user might make between these screens:
1->2->7->2->6 (starts new game, pauses game, returns to game, finishes game) 1->5->1->4->1 (views about screen, goes back to main, views score screen, goes back to main)
I'm really confused about when to have just one activity that switches layouts and when to create new activity classes. For example, when my game loads, I have a "main" activity that loads the main menu layout. When you click the settings button, I launch a "settings" activity (which uses android's standard settings GUI). For the moment, when you start a game, I switch the layout of "main" to the game screen layout (which just contains one big surface view). I'm not really sure what the best way to integrate the game over screen, high score screen, about screen etc.
Creating a new activity for each seems really heavy weight to me. There's quite a lot of boiler plate code involved for each activity. Plus, communication between activities seems like a pain as you have to use bundles. Using just one activity means I can just share object fields directly. It seems that using layouts for the above would be more compact.
Can anyone give me some recommendations?