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); }
@Override protected void onMenuItemPositionReset( final MenuScene pMenuScene, final int pIndex, final IMenuItem pMenuItem, final float pX, final float pY) { final float fromX = getFromX(pMenuScene, pMenuItem, pX); final float fromY = getFromY(pMenuScene, pMenuItem, pY); pMenuItem.setPosition(fromX, fromY); pMenuItem.resetEntityModifiers(); }
@Override public boolean onMenuItemClicked( MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) { // TODO Auto-generated method stub switch (pMenuItem.getID()) { case MENU_PLAY: mainMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f)); mStaticMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f)); mHandler.postDelayed(mLaunchLevel1Task, 1000); return true; case MENU_OPTIONS: mainMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f)); mStaticMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f)); mHandler.postDelayed(mLaunchOptionsTask, 1000); return true; case MENU_HELP: mHandler.postDelayed(mLaunchHelp, 1000); return true; default: return false; } }
@Override public boolean onMenuItemClicked(MenuScene arg0, IMenuItem arg1, float arg2, float arg3) { switch (arg1.getID()) { case MENU_MAINMENU: if (activity.isSfx()) activity.menuClickSound.play(); detachChildren(); activity.setCurrentScene(new MainMenuScene()); activity.runOnUiThread( new Runnable() { @Override public void run() { if (activity.interstitialAd.isLoaded()) { activity.interstitialAd.show(); } else { activity.interstitialAd.loadAd(activity.adRequest); if (activity.interstitialAd.isLoaded()) { activity.interstitialAd.show(); } } } }); return true; default: break; } return false; }
@Override protected void onMenuItemPositionBuilt( final MenuScene pMenuScene, final int pIndex, final IMenuItem pMenuItem, final float pX, final float pY) { final float fromX = getFromX(pMenuScene, pMenuItem, pX); final float fromY = getFromY(pMenuScene, pMenuItem, pY); pMenuItem.setPosition(fromX, fromY); final MoveModifier moveModifier = new MoveModifier(SlideMenuSceneAnimator.DURATION, fromX, fromY, pX, pY, this.mEaseFunction); moveModifier.setAutoUnregisterWhenFinished(false); pMenuItem.registerEntityModifier(moveModifier); }
protected float getFromY(final MenuScene pMenuScene, final IMenuItem pMenuItem, final float pY) { switch (this.mDirection) { case DOWN_LEFT: case DOWN: case DOWN_RIGHT: return pMenuScene.getHeight() + (pMenuItem.getHeight() * 0.5f); case LEFT: case RIGHT: return pY; case UP_LEFT: case UP: case UP_RIGHT: return -(pMenuItem.getHeight() * 0.5f); default: throw new IllegalArgumentException(); } }
public boolean onMenuItemClicked( MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) { switch (pMenuItem.getID()) { case MENU_OPTIONS: SceneManager.getInstance().loadGameScene(engine); return true; default: return false; } }
protected void createStaticMenuScene() { // TODO Auto-generated method stub this.mStaticMenuScene = new MenuScene(this.menuCamera); final IMenuItem playMenuItem = new ScaleMenuItemDecorator( new TextMenuItem( MENU_PLAY, this.mFont, "Play Game", this.getVertexBufferObjectManager()), 2.0f, 1.0f); playMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); this.mStaticMenuScene.addMenuItem(playMenuItem); final IMenuItem optionsMenuItem = new ScaleMenuItemDecorator( new TextMenuItem( MENU_OPTIONS, this.mFont, "Options", this.getVertexBufferObjectManager()), 2.0f, 1.0f); optionsMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); this.mStaticMenuScene.addMenuItem(optionsMenuItem); final IMenuItem helpMenuItem = new ScaleMenuItemDecorator( new TextMenuItem(MENU_HELP, this.mFont, "Help", this.getVertexBufferObjectManager()), 2.0f, 1.0f); helpMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); this.mStaticMenuScene.addMenuItem(helpMenuItem); this.mStaticMenuScene.buildAnimations(); this.mStaticMenuScene.setBackgroundEnabled(false); this.mStaticMenuScene.setOnMenuItemClickListener(this); }
public boolean onMenuItemClicked( MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) { switch (pMenuItem.getID()) { case MENU_PLAY: // Load Game Scene! SceneManager.getInstance().loadGameScene(engine); return true; case MENU_SCORE: showScoreDialog(); return true; default: return false; } }
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); }
@Override public boolean onMenuItemClicked( MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) { switch (pMenuItem.getID()) { case MENU_PLAY: // Load Game Scene! SceneManager.getInstance().loadRampScene(engine, 1); // loadGameScene(engine,3); return true; case MENU_OPTIONS: SceneManager.getInstance().loadSimulationScene(engine); return true; case MENU_LEVEL_SELECTOR: SceneManager.getInstance().createLevelSelectorScene(); return true; default: return false; } }
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; }
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); }
public GameoverScene() { super(BaseActivity.getSharedInstance().mCamera); activity = BaseActivity.getSharedInstance(); setBackground(new Background(Color.WHITE)); attachChild(activity.backgroundSprite); continueText = new Text(0, 0, activity.mFont, "Continue", activity.getVertexBufferObjectManager()); continueText.setPosition( mCamera.getWidth() / 2 - continueText.getWidth() / 2, mCamera.getHeight() - continueText.getHeight() - 20); gameOverText = new Text(0, 0, activity.mFont, "Game Over", activity.getVertexBufferObjectManager()); gameOverText.setPosition( mCamera.getWidth() / 2 - gameOverText.getWidth() / 2, mCamera.getHeight() / 6); scoreText = new Text( 0, 0, activity.mSmallFont, "Score: " + activity.score.getScore(), activity.getVertexBufferObjectManager()); scoreText.setPosition( mCamera.getWidth() / 2 - scoreText.getWidth() / 2, mCamera.getHeight() / 2 - scoreText.getHeight() / 2 - gameOverText.getHeight()); highscoreText = new Text( 0, 0, activity.mSmallFont, "Highscore: " + activity.highscore, activity.getVertexBufferObjectManager()); highscoreText.setPosition( mCamera.getWidth() / 2 - highscoreText.getWidth() / 2, mCamera.getHeight() / 2 - scoreText.getHeight() / 2 - continueText.getHeight() + scoreText.getHeight() + activity.mCamera.getWidth() / 108f); IMenuItem startButton = new SpriteMenuItem( MENU_MAINMENU, activity.buttonRegion, activity.getVertexBufferObjectManager()); startButton.setPosition(mCamera.getWidth() / 10, continueText.getY()); startButton.setSize(mCamera.getWidth() - mCamera.getWidth() / 5, continueText.getHeight()); Sprite panel = new Sprite( mCamera.getWidth() / 10 - mCamera.getWidth() / 20, gameOverText.getY() - 20, activity.panelRegion, activity.getVertexBufferObjectManager()); panel.setSize( mCamera.getWidth() - mCamera.getWidth() / 10, mCamera.getHeight() - panel.getY() - (mCamera.getHeight() - highscoreText.getY()) + highscoreText.getHeight() + 40); attachChild(panel); addMenuItem(startButton); attachChild(gameOverText); attachChild(highscoreText); attachChild(scoreText); attachChild(continueText); setOnMenuItemClickListener(this); if (activity.mGoogleApiClient == null || !activity.mGoogleApiClient.isConnected()) { activity.runOnUiThread( new Runnable() { @Override public void run() { Toast.makeText( activity, "Not connected to Google Play Services. Score not uploaded. Highscore gets uploaded automatically next time.", Toast.LENGTH_LONG) .show(); } }); } }