发布时间:2025-12-09 12:05:35 浏览次数:1
import org.andengine.util.adt.align.HorizontalAlign; //导入依赖的package包/类public void showDeleteConfirm(final SessionSprite sessionSprite) { final Scene scene = this; Dialog confirmDelete = new Dialog(400, 200, Dialog.Buttons.YES_NO, PhoeniciaContext.vboManager, new Dialog.DialogListener() { @Override public void onDialogButtonClicked(Dialog dialog, Dialog.DialogButton dialogButton) { if (dialogButton == Dialog.DialogButton.YES) { Debug.d("delete session"); deleteSession(sessionSprite); } else { Debug.d("Don't delete session"); } dialog.close(); scene.unregisterTouchArea(dialog); } }); confirmDelete.attachChild(new Text(200, 150, GameFonts.dialogText(), "delete saved game?", 18, new TextOptions(HorizontalAlign.CENTER), PhoeniciaContext.vboManager)); scene.registerTouchArea(confirmDelete); confirmDelete.open(scene);} import org.andengine.util.adt.align.HorizontalAlign; //导入依赖的package包/类private void show_sorry() { Dialog sorry_dialog = new Dialog(400, 150, Dialog.Buttons.OK, PhoeniciaContext.vboManager, new Dialog.DialogListener() { @Override public void onDialogButtonClicked(Dialog dialog, Dialog.DialogButton dialogButton) { dialog.close(); unregisterTouchArea(dialog); finish(); } }); String counts = String.format("%1$d/%2$d", this.winnings.size(), this.max_rounds); Text sorry_text = new Text(sorry_dialog.getWidth()/2, sorry_dialog.getHeight()-48, GameFonts.dialogText(), counts, counts.length(), new TextOptions(AutoWrap.WORDS, sorry_dialog.getWidth()*0.8f, HorizontalAlign.CENTER), PhoeniciaContext.vboManager); sorry_text.setColor(Color.RED); sorry_dialog.attachChild(sorry_text); this.registerTouchArea(sorry_dialog); sorry_dialog.open(this); GameSounds.play(GameSounds.FAILED);} import org.andengine.util.adt.align.HorizontalAlign; //导入依赖的package包/类/** * Change the display to the specified IntroPage * @param page_index page to display */private void showPage(int page_index) { Debug.d("Showing page: "+page_index); this.current_page = page_index; final String nextPage = level.intro.get(page_index).text; final TextOptions introTextOptions = new TextOptions(AutoWrap.WORDS, messageBox.getWidth()-64, HorizontalAlign.LEFT); final Text introPageText = new Text(messageBox.getWidth()/2 - 32, messageBox.getHeight()/2, GameFonts.introText(), nextPage, introTextOptions, PhoeniciaContext.vboManager); introPageText.setPosition(messageBox.getWidth() / 2, messageBox.getHeight() - (introPageText.getHeight() / 2)); this.messageBox.setHeight(introPageText.getHeight() + 64); introPageText.setPosition(this.messageBox.getWidth() / 2 + 16, this.messageBox.getHeight() - (introPageText.getHeight() / 2)); messageBox.detachChildren(); messageBox.attachChild(introPageText); messageBox.attachChild(this.nextButton); game.playLevelSound(level.intro.get(page_index).sound, this);} import org.andengine.util.adt.align.HorizontalAlign; //导入依赖的package包/类public DormidaSprite() { super(GameActivity.WORLD_WIDTH / 2, GameActivity.WORLD_HEIGHT / 2, ResourceManager.getInstance().NOTE_BOOK_EMPTY_TEXTURE_REGION, ResourceManager.getInstance().getVertexBuffer()); this.setY(GameActivity.WORLD_HEIGHT + this.getHeight() / 2); float posY = 100; winnerTitle = new Text((this.getWidth()/2)+30,this.getHeight()-posY, ResourceManager.getInstance().fontBig,"123456789",20, new TextOptions(HorizontalAlign.CENTER),ResourceManager.getInstance().getVertexBuffer()); winnerTitle.setText(ResourceManager.getInstance().context.getString(R.string.dormida)); winnerTitle.setColor(0.25490196f, 0.25490196f, 0.25490196f); winnerTitle.setScale(0.7f); this.attachChild(winnerTitle); posY += 120; winnerPlayer = new Text((this.getWidth()/2)+30,this.getHeight()-posY, ResourceManager.getInstance().fontNormal,"123456789",20, new TextOptions(HorizontalAlign.CENTER),ResourceManager.getInstance().getVertexBuffer()); this.attachChild(winnerPlayer); this.setVisible(false);} import org.andengine.util.adt.align.HorizontalAlign; //导入依赖的package包/类protected float getMenuItemX(final MenuScene pMenuScene, final int pIndex) {final float menuSceneWidth = pMenuScene.getWidth();final IMenuItem menuItem = pMenuScene.getMenuItem(pIndex);final float menuItemWidth = menuItem.getWidth();/* Determine horizontal position. */final float x;switch (this.mHorizontalAlign) {case LEFT:x = menuItemWidth * 0.5f;break;case CENTER:x = menuSceneWidth * 0.5f;break;case RIGHT:x = menuSceneWidth - (menuItemWidth * 0.5f);break;default:throw new IllegalArgumentException("Unexpected " + HorizontalAlign.class.getSimpleName() + " with value: '" + this.mHorizontalAlign + "'.");}return x + this.mOffsetX;}