private void createMenuChildScene() { menuChildScene = new MenuScene(camera); menuChildScene.setPosition(0, 0); // SpriteMenuItem smi = new Sp final IMenuItem playMenuItem = new ScaleMenuItemDecorator( new SpriteMenuItem(MENU_PLAY, resourcesManager.play_region, vbom), 1.3f, 1f); final IMenuItem optionsMenuItem = new ScaleMenuItemDecorator( new SpriteMenuItem(MENU_OPTIONS, resourcesManager.options_region, vbom), 1.3f, 1f); final IMenuItem levelSelectorMenuItem = new ScaleMenuItemDecorator( new SpriteMenuItem(MENU_LEVEL_SELECTOR, resourcesManager.simulation_region, vbom), 1.3f, 1f); menuChildScene.addMenuItem(playMenuItem); menuChildScene.addMenuItem(levelSelectorMenuItem); menuChildScene.addMenuItem(optionsMenuItem); menuChildScene.buildAnimations(); menuChildScene.setBackgroundEnabled(false); playMenuItem.setPosition(playMenuItem.getX() - 130, playMenuItem.getY() - 200); optionsMenuItem.setPosition(optionsMenuItem.getX(), optionsMenuItem.getY() - 170); levelSelectorMenuItem.setPosition( levelSelectorMenuItem.getX() + 125, levelSelectorMenuItem.getY() - 145); menuChildScene.setOnMenuItemClickListener(this); setChildScene(menuChildScene); }
private void createMenuChildScene() { submenuChildScene = new MenuScene(camera); submenuChildScene.setPosition(WIDTH, HEIGHT); final IMenuItem optionsMenuItem = new ScaleMenuItemDecorator( new SpriteMenuItem(MENU_OPTIONS, resourcesManager.submenu_item1_region, vbom), 1.2f, 1); // final IMenuItem quitMenuItem = new ScaleMenuItemDecorator(new // SpriteMenuItem(MENU_QUIT,resourcesManager.quit_region,vbom),1.2f,1); submenuChildScene.addMenuItem(optionsMenuItem); submenuChildScene.buildAnimations(); // must setposition after it unless it has no effect submenuChildScene.setBackgroundEnabled(false); // playMenuItem.setPosition(playMenuItem.getX()-20, playMenuItem.getY() - 150); // optionsMenuItem.setPosition(optionsMenuItem.getX()-20, optionsMenuItem.getY() - 110); optionsMenuItem.setPosition( (WIDTH / 2 - optionsMenuItem.getWidth() / 2) - 50, (HEIGHT / 2 - optionsMenuItem.getHeight() / 2) - 50); submenuChildScene.setOnMenuItemClickListener(this); setChildScene(submenuChildScene); }
private void agregaMenu() { menu = new MenuScene(actividadJuego.camara); // Centrado en la pantalla menu.setPosition(ControlJuego.ANCHO_CAMARA / 2, ControlJuego.ALTO_CAMARA / 2); IMenuItem opcionContinue = new ScaleMenuItemDecorator( new SpriteMenuItem( OPCION_CONTINUE, regionBtnContinue, actividadJuego.getVertexBufferObjectManager()), 1.5f, 1); menu.addMenuItem(opcionContinue); levelUp = new ScaleMenuItemDecorator( new SpriteMenuItem( OPCION_LEVELUP, regionLevelUp, actividadJuego.getVertexBufferObjectManager()), 1, 1); menu.addMenuItem(levelUp); levelUp.setVisible(false); if (didILevelUp == true) { levelUp.setVisible(true); } menu.buildAnimations(); menu.setBackgroundEnabled(false); opcionContinue.setPosition(450, -240); levelUp.setPosition(450, -110); menu.setOnMenuItemClickListener( new MenuScene.IOnMenuItemClickListener() { @Override public boolean onMenuItemClicked( MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) { // El parámetro pMenuItem indica la opción oprimida switch (pMenuItem.getID()) { case OPCION_CONTINUE: if (playerwin == true) { admEscenas.crearEscenaBatalla2(); admEscenas.setEscena(TipoEscena.ESCENA_BATALLA2); admEscenas.liberarEscenaFinBatalla(); } else if (playerwin == false) { admEscenas.crearEscenaBatalla(); admEscenas.setEscena(TipoEscena.ESCENA_BATALLA); admEscenas.liberarEscenaFinBatalla(); } break; } return true; } }); setChildScene(menu); }
private void createMenuChildScene() { menuChildScene = new org.andengine.entity.scene.menu.MenuScene(camera); menuChildScene.setPosition(0, 0); final IMenuItem playMenuItem = new ScaleMenuItemDecorator(new SpriteMenuItem(MENU_PLAY, play_region, vbom), 1.2f, 1); final IMenuItem optionsMenuItem = new ScaleMenuItemDecorator(new SpriteMenuItem(MENU_OPTIONS, options_region, vbom), 1.2f, 1); menuChildScene.addMenuItem(playMenuItem); menuChildScene.addMenuItem(optionsMenuItem); menuChildScene.buildAnimations(); menuChildScene.setBackgroundEnabled(false); playMenuItem.setPosition(playMenuItem.getX(), playMenuItem.getY()); optionsMenuItem.setPosition(optionsMenuItem.getX(), optionsMenuItem.getY()); menuChildScene.setOnMenuItemClickListener( new IOnMenuItemClickListener() { @Override public boolean onMenuItemClicked( org.andengine.entity.scene.menu.MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) { switch (pMenuItem.getID()) { case MENU_PLAY: sceneManager.loadGameScene(); sceneManager.createGameScene(); sceneManager.goToGameScene(); return true; case MENU_OPTIONS: return true; default: return false; } } }); setChildScene(menuChildScene); }
private void createMenuChildScene() { menuChildScene = new MenuScene(camera); final IMenuItem playMenuItem = new ScaleMenuItemDecorator( new SpriteMenuItem(MENU_PLAY, resourcesManager.play_region, vbom), 1.2f, 1); final IMenuItem scoreMenuItem = new ScaleMenuItemDecorator( new SpriteMenuItem(MENU_SCORE, resourcesManager.highScores_region, vbom), 1.2f, 1); menuChildScene.addMenuItem(playMenuItem); menuChildScene.addMenuItem(scoreMenuItem); menuChildScene.buildAnimations(); menuChildScene.setBackgroundEnabled(false); playMenuItem.setPosition(playMenuItem.getX(), playMenuItem.getY() - 20); scoreMenuItem.setPosition(scoreMenuItem.getX(), scoreMenuItem.getY()); menuChildScene.setOnMenuItemClickListener(this); setChildScene(menuChildScene); }
public org.andengine.entity.scene.menu.MenuScene createScene() { float screenWidth = camera.getWidth(); float screenHeight = camera.getHeight(); menuScene = new org.andengine.entity.scene.menu.MenuScene(camera); // BACKGROUND SETUP map.loadMap(menuScene); // menuScene.attachChild(map.createScene(10)); spawnCar(screenWidth, screenHeight); // BANNER/LOGO & banner animation final Sprite banner = new Sprite( (screenWidth - dodgecarsTR.getWidth()) / 2, (screenHeight / 7) / 2, dodgecarsTR, this.activity.getVertexBufferObjectManager()); rotBan = false; scaBan = false; banner.registerEntityModifier( new ScaleModifier(scaleDuration, startScale, endScale) { @Override protected void onModifierFinished(IEntity pItem) { super.onModifierFinished(pItem); if (scaBan) { this.reset(scaleDuration, startScale, endScale, startScale, endScale); scaBan = !scaBan; } else { this.reset(scaleDuration, endScale, startScale, endScale, startScale); scaBan = !scaBan; } } }); banner.registerEntityModifier( new RotationModifier(rotDuration, startRot, endRot) { @Override protected void onModifierFinished(IEntity pItem) { super.onModifierFinished(pItem); if (!rotBan) { this.reset(rotDuration, endRot, startRot); rotBan = !rotBan; } else { this.reset(rotDuration, startRot, endRot); rotBan = !rotBan; } } }); // MENU ITEMS final IMenuItem buttonPlay = new ScaleMenuItemDecorator( new SpriteMenuItem(PLAY_BTN_ID, playTR, this.activity.getVertexBufferObjectManager()), unSelected, onSelected); final IMenuItem buttonHighScore = new ScaleMenuItemDecorator( new SpriteMenuItem( HIGHSCORE_BTN_ID, highscoreTR, this.activity.getVertexBufferObjectManager()), unSelected, onSelected); final IMenuItem buttonCredits = new ScaleMenuItemDecorator( new SpriteMenuItem( CREDITS_BTN_ID, creditsTR, this.activity.getVertexBufferObjectManager()), unSelected, onSelected); buttonPlay.setPosition((screenWidth - playTR.getWidth()) / 2, screenHeight / 7 * 3); buttonHighScore.setPosition((screenWidth - highscoreTR.getWidth()) / 2, screenHeight / 7 * 4); buttonCredits.setPosition((screenWidth - creditsTR.getWidth()) / 2, screenHeight / 7 * 5); // Sound and Music on/off buttons soundOnBtn = new Sprite( camera.getWidth() - soundsOnTR.getWidth() * 2, 0, soundsOnTR, this.activity.getVertexBufferObjectManager()); soundOffBtn = new Sprite( camera.getWidth() - soundsOnTR.getWidth() * 2, 0, soundsOffTR, this.activity.getVertexBufferObjectManager()); musicOnBtn = new Sprite( camera.getWidth() - musicOnTR.getWidth(), 0, musicOnTR, this.activity.getVertexBufferObjectManager()); musicOffBtn = new Sprite( camera.getWidth() - musicOnTR.getWidth(), 0, musicOffTR, this.activity.getVertexBufferObjectManager()); menuScene.attachChild(banner); menuScene.addMenuItem(buttonPlay); menuScene.addMenuItem(buttonHighScore); menuScene.addMenuItem(buttonCredits); if (sounds.playMusic) { menuScene.attachChild(musicOffBtn); menuScene.attachChild(musicOnBtn); musicOffBtn.setVisible(false); musicOnBtn.setVisible(true); } else { menuScene.attachChild(musicOnBtn); menuScene.attachChild(musicOffBtn); musicOnBtn.setVisible(false); musicOffBtn.setVisible(true); } if (sounds.playSounds) { menuScene.attachChild(soundOffBtn); menuScene.attachChild(soundOnBtn); soundOffBtn.setVisible(false); soundOnBtn.setVisible(true); } else { menuScene.attachChild(soundOnBtn); menuScene.attachChild(soundOffBtn); soundOnBtn.setVisible(false); soundOffBtn.setVisible(true); } final Rectangle soundRec = new Rectangle( camera.getWidth() - soundsOnTR.getWidth() * 2, 0, GameManager.lengthOfTile, GameManager.lengthOfTile, this.activity.getVertexBufferObjectManager()) { public boolean onAreaTouched(TouchEvent touchEvent, float X, float Y) { if (touchEvent.isActionDown()) { if (sounds.playSounds) { sounds.setSoundsEnable(false); soundOnBtn.setVisible(false); soundOffBtn.setVisible(true); } else { sounds.setSoundsEnable(true); soundOffBtn.setVisible(false); soundOnBtn.setVisible(true); } } return true; }; }; final Rectangle musicRec = new Rectangle( camera.getWidth() - musicOnTR.getWidth(), 0, GameManager.lengthOfTile, GameManager.lengthOfTile, this.activity.getVertexBufferObjectManager()) { public boolean onAreaTouched(TouchEvent touchEvent, float X, float Y) { if (touchEvent.isActionDown()) { if (sounds.playMusic) { sounds.setMusicEnable(false); sounds.pauseMusic(); musicOnBtn.setVisible(false); musicOffBtn.setVisible(true); } else { sounds.setMusicEnable(true); sounds.playMusic(); musicOffBtn.setVisible(false); musicOnBtn.setVisible(true); } } return true; }; }; soundRec.setAlpha(255); musicRec.setAlpha(255); menuScene.registerTouchArea(soundRec); menuScene.registerTouchArea(musicRec); menuScene.attachChild(soundRec); menuScene.attachChild(musicRec); menuScene.setOnMenuItemClickListener( new IOnMenuItemClickListener() { @Override public boolean onMenuItemClicked( org.andengine.entity.scene.menu.MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) { switch (pMenuItem.getID()) { case PLAY_BTN_ID: sounds.playCarStart(); sceneManager.createGameScene(); sceneManager.setCurrentSence(AllScenes.GAME); break; case HIGHSCORE_BTN_ID: sounds.playBlop(); sceneManager.createHighScoreScene(); sceneManager.setCurrentSence(AllScenes.HIGHSCORE); break; case CREDITS_BTN_ID: sounds.playBlop(); sceneManager.createCreditScene(); sceneManager.setCurrentSence(AllScenes.CREDITS); break; } return false; } }); return menuScene; }
public org.andengine.entity.scene.menu.MenuScene createScene() { scene = new org.andengine.entity.scene.menu.MenuScene(camera); map.loadMap(scene); int padding = 50; final Sprite credits = new Sprite( (camera.getWidth() - creditsTR.getWidth()) / 2, GameManager.lengthOfTile * 2, creditsTR, this.activity.getVertexBufferObjectManager()); final Sprite gameby = new Sprite( (camera.getWidth() - gamebyTR.getWidth()) / 2, GameManager.lengthOfTile * 2 + creditsTR.getHeight() + padding * 2, gamebyTR, this.activity.getVertexBufferObjectManager()); final Sprite robin = new Sprite( (camera.getWidth() - robinTR.getWidth()) / 2, GameManager.lengthOfTile * 2 + creditsTR.getHeight() + gamebyTR.getHeight() + padding * 3, robinTR, this.activity.getVertexBufferObjectManager()); final Sprite musicby = new Sprite( (camera.getWidth() - musicbyTR.getWidth()) / 2, GameManager.lengthOfTile * 2 + creditsTR.getHeight() + gamebyTR.getHeight() + robinTR.getHeight() + padding * 5, musicbyTR, this.activity.getVertexBufferObjectManager()); final Sprite alex = new Sprite( (camera.getWidth() - alexTR.getWidth()) / 2, GameManager.lengthOfTile * 2 + creditsTR.getHeight() + gamebyTR.getHeight() + robinTR.getHeight() + musicbyTR.getHeight() + padding * 6, alexTR, this.activity.getVertexBufferObjectManager()); scene.attachChild(gameby); scene.attachChild(alex); scene.attachChild(musicby); scene.attachChild(robin); final IMenuItem buttonHome = new ScaleMenuItemDecorator( new SpriteMenuItem(HOME_BTN_ID, homeTR, this.activity.getVertexBufferObjectManager()), 1, 1); buttonHome.setPosition( camera.getWidth() / 2 - homeTR.getWidth() / 2, camera.getHeight() - homeTR.getHeight() * 2); scene.addMenuItem(buttonHome); scene.setOnMenuItemClickListener( new IOnMenuItemClickListener() { @Override public boolean onMenuItemClicked( org.andengine.entity.scene.menu.MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) { switch (pMenuItem.getID()) { case HOME_BTN_ID: sounds.playBlop(); sceneManager.createMenuScene(); sceneManager.setCurrentSence(AllScenes.MENU); break; } return false; } }); scene.attachChild(credits); return scene; }