private void createHUD() { gameHUD = new HUD(); scoreText = new Text(0, 0, resourcesManager.gameFont, "Loading...", vbom); scoreText.setSkewCenter(0, 0); scoreText.setText("Score: 0"); scoreText.setColor(Color.BLACK); gameHUD.attachChild(scoreText); timeText = new Text(380, 10, resourcesManager.gameFont, "Loading...", vbom); timeText.setSkewCenter(0, 0); timeText.setText(String.valueOf(timeLeft)); timeText.setColor(Color.BLACK); gameHUD.attachChild(timeText); gameHUD.setChildScene(joystick); camera.setHUD(gameHUD); }
public void createShootButton() { ButtonSprite shoot = new ButtonSprite( camera.getWidth() - resourcesManager.shootButtonTextureRegion.getWidth(), camera.getHeight() - resourcesManager.shootButtonTextureRegion.getHeight(), resourcesManager.shootButtonTextureRegion, vbom) { public boolean onAreaTouched( TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) { if (pSceneTouchEvent.isActionDown()) { setScale(1.25f); for (int i = 0; i < birdArray.size(); i++) { if (birdUnderAim(birdArray.get(i))) { Log.e("GAME", "birdUnderAim"); birdArray.get(i).clearEntityModifiers(); birdArray.get(i).onDie(); plumageArray.add( new Plumage( birdArray.get(i).getX(), birdArray.get(i).getY(), birdArray.get(i).currentType)); Log.e("GAME", "PLUMAGE CREATING" + plumageArray.size()); SceneManager.getInstance().getCurrentScene().attachChild(plumageArray.getLast()); AddToPool(i); } } } if (pSceneTouchEvent.isActionUp()) { setScale(1f); } return true; }; }; gameHUD.attachChild(shoot); gameHUD.registerTouchArea(shoot); }
private void createHUD() { gameHUD = new HUD(); t_score_text = new Text( shift_row / 2, 6 * GameActivity.getCameraHeight() / 7, m_resource_manager.font, "Score: 0123456789", new TextOptions(org.andengine.util.adt.align.HorizontalAlign.CENTER), m_vbom); t_score_text.setSkewCenter(0, 0); t_score_text.setText("Score: \n 0"); t_score_text.setPosition(t_score_text.getWidth(), 6 * GameActivity.getCameraHeight() / 7); gameHUD.attachChild(t_score_text); m_camera.setHUD(gameHUD); _score = new Score(_level); _score.setTextScore(t_score_text); }
public GameDialogBox(HUD hud, String message, int back, boolean text, ButtonSprite... buttons) { super(); dismissed = false; this.buttons = buttons; this.hud = hud; this.text = text; ResourcesManager resourcesManager = ResourcesManager.getInstance(); // Attach Background switch (back) { case 1: hud.attachChild( backgroundSprite = new Sprite(240, 400, resourcesManager.dialog_background, resourcesManager.vbom)); break; case 2: if (resourcesManager.dialog_background2 == null) { Log.d("Null", "null"); } hud.attachChild( backgroundSprite = new Sprite(240, 400, resourcesManager.dialog_background2, resourcesManager.vbom)); break; case 3: hud.attachChild( backgroundSprite = new Sprite(240, 400, resourcesManager.dialog_background3, resourcesManager.vbom)); break; default: break; } if (text) { messageText = new Text( 240, 400, resourcesManager.cartoon_font_white, message, new TextOptions( AutoWrap.WORDS, backgroundSprite.getWidth() - 100, HorizontalAlign.CENTER, Text.LEADING_DEFAULT), resourcesManager.vbom); hud.attachChild(messageText); if (400 + (backgroundSprite.getHeight() / 2) - 50 + (messageText.getHeight() / 2) > 400 + backgroundSprite.getHeight() / 2) { messageText.setPosition(240, 400 + backgroundSprite.getHeight() / 2 - 100); j = 400 + (backgroundSprite.getHeight() / 2 - 100) - messageText.getHeight() - 25; } else { messageText.setPosition(240, 400 + backgroundSprite.getHeight() / 2 - 50); j = 400 + (backgroundSprite.getHeight() / 2 - 50) - messageText.getHeight() - 25; } } else { j = 400 + ((buttons.length * 100) / 2); } int i = 0; for (ButtonSprite button : buttons) { hud.attachChild(button); button.setPosition(240, j - (100 * i)); hud.registerTouchArea(button); i++; } // hud.registerTouchArea(okayButton); }
private void createHUD() { minigameHUD = new HUD(); // Textures BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); HUDTextureAtlas = new BitmapTextureAtlas( ResourcesManager.getInstance().activity.getTextureManager(), 256, 256); blueHeartTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset( HUDTextureAtlas, ResourcesManager.getInstance().activity, "heartBlue.png", 0, 0); greenHeartTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset( HUDTextureAtlas, ResourcesManager.getInstance().activity, "heartGreen.png", 50, 0); yellowHeartTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset( HUDTextureAtlas, ResourcesManager.getInstance().activity, "heartYellow.png", 0, 50); redHeartTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset( HUDTextureAtlas, ResourcesManager.getInstance().activity, "heartRed.png", 50, 50); timerTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset( HUDTextureAtlas, ResourcesManager.getInstance().activity, "timer.png", 110, 110); timerSprite = new Sprite(0, 0, timerTR, vbom); redHeartSprite = new Sprite(0, 0, redHeartTR, vbom); yellowHeartSprite = new Sprite(0, 0, yellowHeartTR, vbom); greenHeartSprite = new Sprite(0, 0, greenHeartTR, vbom); blueHeartSprite = new Sprite(0, 0, blueHeartTR, vbom); timerSprite.setPosition(timerTR.getWidth() / 2, camera.getHeight() - timerTR.getHeight()); if (PlayerManager.getInstance().player.getPlayerName().equalsIgnoreCase("Player 1")) { redHeartSprite.setPosition( 2 + redHeartTR.getWidth() / 2, timerSprite.getY() - redHeartTR.getHeight() - 5); yellowHeartSprite.setPosition( camera.getWidth() - (yellowHeartTR.getWidth() / 2) - 2, camera.getHeight() - (yellowHeartTR.getHeight() / 2) - 2); } else { redHeartSprite.setPosition( camera.getWidth() - (yellowHeartTR.getWidth() / 2) - 2, camera.getHeight() - (yellowHeartTR.getHeight() / 2) - 2); yellowHeartSprite.setPosition( 2 + redHeartTR.getWidth() / 2, timerSprite.getY() - redHeartTR.getHeight() - 5); } greenHeartSprite.setPosition( yellowHeartSprite.getX() - greenHeartTR.getWidth() - 5, yellowHeartSprite.getY()); blueHeartSprite.setPosition( greenHeartSprite.getX() - blueHeartTR.getWidth() - 5, greenHeartSprite.getY()); // Timer timeLeft = MinigameManager.TIMER_SECONDS; timerText = new Text( 0, 0, resourcesManager.font, "0123456789", new TextOptions(HorizontalAlign.LEFT), vbom); timerText.setText(timeLeft + ""); timerText.setPosition(50, camera.getHeight() - timerText.getHeight() / 2); // Player lives p1LivesLeft = 10; p2LivesLeft = 10; p3LivesLeft = 10; p4LivesLeft = 10; p1LivesText = new Text( 0, 0, resourcesManager.p1LivesFont, "0123456789", new TextOptions(HorizontalAlign.LEFT), vbom); p2LivesText = new Text( 0, 0, resourcesManager.p1LivesFont, "0123456789", new TextOptions(HorizontalAlign.LEFT), vbom); p3LivesText = new Text( 0, 0, resourcesManager.p1LivesFont, "0123456789", new TextOptions(HorizontalAlign.LEFT), vbom); p4LivesText = new Text( 0, 0, resourcesManager.p1LivesFont, "0123456789", new TextOptions(HorizontalAlign.LEFT), vbom); p1LivesText.setPosition(redHeartSprite.getX(), redHeartSprite.getY()); p2LivesText.setPosition(blueHeartSprite.getX(), blueHeartSprite.getY()); p3LivesText.setPosition(greenHeartSprite.getX(), greenHeartSprite.getY()); p4LivesText.setPosition(yellowHeartSprite.getX(), yellowHeartSprite.getY()); p1LivesText.setText(PlayerManager.getInstance().player1.getPlayerHearts() + ""); // p3LivesText.setText(p3LivesLeft + ""); // p4LivesText.setText(p4LivesLeft + ""); // Attach HUDTextureAtlas.load(); // minigameHUD.attachChild(blueHeartSprite); minigameHUD.attachChild(redHeartSprite); // minigameHUD.attachChild(greenHeartSprite); minigameHUD.attachChild(timerSprite); minigameHUD.attachChild(timerText); minigameHUD.attachChild(p1LivesText); // minigameHUD.attachChild(p2LivesText); // minigameHUD.attachChild(p3LivesText); if (PlayerManager.getInstance().player2 != null) { p4LivesText.setText(PlayerManager.getInstance().player2.getPlayerHearts() + ""); minigameHUD.attachChild(yellowHeartSprite); minigameHUD.attachChild(p4LivesText); } camera.setHUD(minigameHUD); }