Game Development Reference
In-Depth Information
Listing 7-4. Game Menu and Selection
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, 0, 0, "Start").setIcon(R.drawable.icon);
menu.add(0, 2, 2, "Install Game").setIcon(R.drawable.install);
menu.add(0, 3, 3, "Navigation").setIcon(R.drawable.nav);
menu.add(0, 6, 6, "Exit").setIcon(R.drawable.exit);
return true;
}
/**
* Menu selection
*/
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
switch (item.getItemId()) {
case 0:
if ( mGameStarted) {
MessageBox("Game already in progress.");
return true;
}
mMultiPlayer = false;
showLauncherDialog(this, mMultiPlayer);
return true;
case 2:
if ( mGameStarted) {
MessageBox("Can't install while game in progress.");
return true;
}
// SD card required
if ( ! DoomTools.checkSDCard(this) ) return true;
// Download Game file
DialogTool.showDownloadDialog(this);
return true;
case 3:
DialogTool.showNavMethodDialog(this);
return true;
case 6:
// Exit
DoomTools.hardExit(0);
return true;
}
return false;
}
Search WWH ::




Custom Search