Game Development Reference
In-Depth Information
GameFileDownloader.java : This class is capable of downloading
shareware game files from the Internet into the SD card.
LibraryLoader.java : This class loads the DSO, which is required
before the native methods can be invoked.
WebDownload.java : This is a web download tool used by the
GameFileDownloader class.
Again, before you look at these components in more detail, make sure you have the chapter
code at hand; most of the listings have been stripped down for simplicity.
Java Main Activity
The main activity class is invoked when the user starts the game and controls the life cycle
of the application. In Doom, this life cycle is handled by the following:
Creation handler : This handler is implemented by onCreate and it is
called when the activity is first created. It sets the UI layout XML
( doom.xml ) and initializes the game.
Menu handlers : Here you have onCreateOptionsMenu and
onOptionsItemSelected . The first method creates the game menu and
the latter processes the menu when the user selects an option.
Key and touch handlers : These methods receive key and touch events
and dispatch them to the right JNI component.
Native callback handlers : These methods receive video and sound
updates from the native interface and dispatch them.
Controller toolbar : The controller toolbar is a set of image buttons
displayed at the bottom of the screen for navigation. It is helpful for
devices that do not have a keyboard.
Creation Handler
The creation handler is defined by onCreate (see Listing 5-2). For Doom, this method
performs the following steps:
1.
Sets the display to full screen and hides the title.
Sets the content view layout to R.layout.doom , which maps to
doom.xml.
2.
Gets a reference to the video buffer ( R.id.doom_iv ), which will be
used to display the pixels sent by the DSO.
3.
4.
Sets the navigation controls.
 
Search WWH ::




Custom Search