本文整理汇总了Java中org.andengine.entity.scene.menu.item.IMenuItem.getID方法的典型用法代码示例。如果您正苦于以下问题:Java IMenuItem.getID方法的具体用法?Java IMenuItem.getID怎么用?Java IMenuItem.getID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.entity.scene.menu.item.IMenuItem
的用法示例。
在下文中一共展示了IMenuItem.getID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMenuItemClicked
import org.andengine.entity.scene.menu.item.IMenuItem; //导入方法依赖的package包/类
@Override
public boolean onMenuItemClicked(MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) {
int id = pMenuItem.getID();
Logger.log(TAG, "Menu item clicked");
for (int menuId : mLevels) {
if (id == menuId) {
Logger.log(TAG, "Selected level " + menuId);
AbstractGameActivity activity = getActivity();
if (activity != null) {
Logger.log(TAG, "Creating game scene");
SceneManager sceneManager = activity.getSceneManager();
sceneManager.uploadScene(SceneType.GAME_SCENE);
GameScene gameScene = (GameScene) sceneManager.getScene(SceneType.GAME_SCENE);
gameScene.setLevel(menuId);
gameScene.populateScene();
activity.getEngine().setScene(gameScene);
return true;
}
return false;
}
}
return false;
}
示例2: onMenuItemClicked
import org.andengine.entity.scene.menu.item.IMenuItem; //导入方法依赖的package包/类
@Override
public boolean onMenuItemClicked(MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) {
switch (pMenuItem.getID()) {
case OPTION_QUIT:
onQuit();
return true;
case OPTION_RESET:
currentGame.logLevelEnd(currentGame.getScore(), false);
currentGame.logLevelStart();
currentGame.setPlaying(true);
currentGame.resetGame();
gameScene.clearChildScene();
music.seekTo(0);
music.play();
resetMenus();
return true;
case OPTION_NEXT:
final Resources resources = getResources();
final int nextGameId = currentGame.getNextGameId();
if (nextGameId != BaseGame.ID_NONE) {
final boolean nextGameIsPortrait = BaseGame.isPortrait(nextGameId);
if (nextGameIsPortrait == currentGame.isPortrait()) {
currentGame = BaseGame.getGameFromTag(nextGameId, this);
updateNextStatus();
resetMenus();
loadGameAsync();
mEngine.setScene(splashScene);
} else {
BaseGame.startGame(this, nextGameId);
warnAboutOrientation();
onQuit();
}
} else {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), resources.getString(R.string.msg_last_game), Toast.LENGTH_SHORT).show();
}
});
NavUtils.navigateUpFromSameTask(AbstractGameActivity.this);
}
return true;
}
return false;
}