Determining Application Activity Requirements

You need to implement five activity classes, one for each feature of the game:

► SplashActivity—This activity serves as the default activity to launch. It simply displays a layout (maybe just a big graphic), plays music for several seconds, and then launches MenuActivity.

► MenuActivity—This activity is pretty straightforward. Its layout has several buttons, each corresponding to a feature of the application. The onClick() handlers for each button trigger cause the associated activity to launch.

► PlayActivity—The real application guts are implemented here. This activity needs to draw stuff onscreen, handle various types of user input, keep score, and generally follow whatever game dynamics the developer wants to support.

► ScoresActivity—This activity is about as simple as SplashActivity. It does little more than load a bunch of scoring information into a TextView control within its layout.

► HelpActivity—This activity is almost identical to ScoresActivity, except that instead of displaying scores, it displays help text. Its TextView control might possibly scroll.

Each activity class should have its own corresponding layout file stored in the application resources. You could use a single layout file for ScoresActivity and HelpActivity, but it's not necessary. If you did, though, you would simply create a single layout for both and set the image in the background and the text in the TextView control at runtime, instead of within the layout file.

Figure 3.1 shows the resulting design for your game, Chippy's Revenge Version 0.0.1 for Android.

Figure 3.1 shows the resulting design for your game, Chippy's Revenge Version 0.0.1 for Android.

Default Launch Activity Started

Help Button onClick()

Play Button onClick() Launches Play Activity

Help Button onClick()

Help Activity

0k

■bit cvUccUnf

p." ■ • ^^ ^

Default Launch Activity Started

USER LAUNCHES APPLICATION

USER LAUNCHES APPLICATION

Play Button onClick() Launches Play Activity

Score Button onClick() Launches Scores Activity

Play Activity

LEVEL

"Nuts Will Roll"

nuti

FIGURE 3.1

Application design of a simple Android application (Chippy's Revenge).

0 0

Post a comment