public Shadow(AbstractBulletView unitView, AbstractScreen screen) { mUnitView = unitView; mShadow = new Image(screen.getTextures().get("shadow.png")); mShadow.setWidth(unitView.getWidth() * .75f); mShadow.setHeight(Math.max(15, unitView.getHeight() * .1f)); mShadow.setY(-mShadow.getHeight()); mShadow.setX((mUnitView.getWidth() - mShadow.getWidth()) / 2); mUnitView.addActor(mShadow); }
public Modul(Spiel spiel) { this.skin = spiel.gebeSkin(); this.spiel = spiel; addActor(new Image(skin, "Modul")); addActor(new Image(skin, "Gitter")); this.imageLED = new Image(skin, "LED"); imageLED.setPosition(BREITE - imageLED.getWidth() - 3, HOEHE - imageLED.getHeight() - 3); addActor(imageLED); setSize(BREITE, HOEHE); }
private void mainInit() { Image logo; logo = new Image(new Texture("resources/logo.png")); logo.setPosition(16, 300); logo.setOrigin(logo.getWidth() / 2, logo.getHeight() / 2); RepeatAction twinkleForever = new RepeatAction(); twinkleForever.setAction(new SequenceAction(CustomActions.twinkle(), new DelayAction(1.3f))); twinkleForever.setCount(RepeatAction.FOREVER); logo.addAction(twinkleForever); music = Gdx.audio.newMusic(Gdx.files.internal("resources/music/main.mp3")); music.play(); stage.addActor(logo); }
private Image makeHappyDroidsLogo(TextureAtlas atlas) { Image happyDroidsLogo = new Image(atlas.findRegion("happy-droids-logo")); happyDroidsLogo.getColor().a = 0f; happyDroidsLogo.addAction(Actions.fadeIn(0.125f)); happyDroidsLogo.setX( getStage().getWidth() - happyDroidsLogo.getWidth() - Display.devicePixel(5)); happyDroidsLogo.setY(Display.devicePixel(5)); happyDroidsLogo.addListener( new VibrateClickListener() { @Override public void onClick(InputEvent event, float x, float y) { Platform.getBrowserUtil().launchWebBrowser(TowerConsts.HAPPYDROIDS_URI); } }); return happyDroidsLogo; }
private Image getButton(SpriteBatch batch, String text, int textColor) { // final BitmapFont font = Utility.getFont(); // font.setColor(textColor); // font.setScale(0.25f); // final int h = (int) (font.getLineHeight() * 1.6f); // final int w = (int) (width / 2.8f); // // final Pixmap pixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888); // pixmap.setColor(0xffffffff); // Pixmap.setFilter(Pixmap.Filter.BiLinear); // final int cy = h / 2; // // pixmap.fillCircle(cy, cy, cy); // pixmap.fillRectangle(cy, 0, w - cy - cy, pixmap.getHeight()); // pixmap.fillCircle(w - cy, cy, cy); // // final Texture texture = new Texture(pixmap); // // Gdx.gl.glClearColor(0.8627f, 0.8627f, 0.8627f, 1); // Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // final float textWidth = font.getBounds(text).width; // final float textHeight = font.getLineHeight(); // int x = w / 2; // int y = h / 2; // batch.begin(); // batch.draw(texture, 0, 0); // font.draw(batch, text, x - textWidth / 2, y + (textHeight / 3)); // batch.end(); // texture.dispose(); // pixmap.dispose(); final Image image = new Image(ScreenUtils.getFrameBufferTexture(0, 0, 90, 90)); image.setOrigin(image.getWidth() / 2, image.getHeight() / 2); image.setUserObject(text); return image; }
private Table buildControlsLayer() { Table layer = new Table(); imgPause = new Image(skinCanyonBunny, "pause"); layer.addActor(imgPause); imgPause.setScale(Constants.SCALE + 0.5f); imgPause.setOrigin(imgPause.getWidth() / 2f, imgPause.getHeight() / 2f); imgPause.setPosition( (Gdx.graphics.getWidth() - imgPause.getWidth()) / 2f, Gdx.graphics.getHeight() * 0.8f); btnResume = new Button(skinCanyonBunny, "resume"); layer.addActor(btnResume); btnResume.setSize( btnResume.getWidth() * Constants.SCALE, btnResume.getHeight() * Constants.SCALE); btnResume.setPosition( (Gdx.graphics.getWidth() - btnResume.getWidth()) / 2f, Gdx.graphics.getHeight() * 0.6f); btnResume.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (continueGame) { gameService.getScene(TowerDefenseScene.class).setInputProcessor(); gameService.changeScene(TowerDefenseScene.class); gameService.getScene(TowerDefenseScene.class).resume(); } } }); if (!continueGame) { btnResume.setColor( btnResume.getColor().r, btnResume.getColor().g, btnResume.getColor().b, 0.5f); } btnRestart = new Button(skinCanyonBunny, "restart"); layer.addActor(btnRestart); btnRestart.setSize( btnRestart.getWidth() * Constants.SCALE, btnRestart.getHeight() * Constants.SCALE); btnRestart.setPosition( (Gdx.graphics.getWidth() - btnRestart.getWidth()) / 2f, Gdx.graphics.getHeight() * 0.45f); btnRestart.addListener( new ChangeListener() { @SuppressWarnings("static-access") @Override public void changed(ChangeEvent event, Actor actor) { if (restartGame) { gameService .getScene(TowerDefenseScene.class) .loadMap(gameService.getService(Level.class).getLevelIndex()); gameService.getScene(TowerDefenseScene.class).setInputProcessor(); gameService.changeScene(TowerDefenseScene.class); gameService.getScene(TowerDefenseScene.class).hideEditWeapon(); gameService.getService(Player.class).towerRange.visible = false; } } }); if (!restartGame) { btnRestart.setColor( btnRestart.getColor().r, btnRestart.getColor().g, btnRestart.getColor().b, 0.5f); } btnLevel = new Button(skinCanyonBunny, "levelchoice"); layer.addActor(btnLevel); btnLevel.setSize(btnLevel.getWidth() * Constants.SCALE, btnLevel.getHeight() * Constants.SCALE); btnLevel.setPosition( (Gdx.graphics.getWidth() - btnLevel.getWidth()) / 2f, Gdx.graphics.getHeight() * 0.3f); btnLevel.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { gameService.getScene(LevelScene.class).setInputProcessor(); gameService.changeScene(LevelScene.class); } }); btnMenu = new Button(skinCanyonBunny, "menu"); layer.addActor(btnMenu); btnMenu.setSize(btnMenu.getWidth() * Constants.SCALE, btnMenu.getHeight() * Constants.SCALE); btnMenu.setPosition( (Gdx.graphics.getWidth() - btnMenu.getWidth()) / 2f, Gdx.graphics.getHeight() * 0.15f); btnMenu.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { gameService.getScene(MenuScene.class).setInputProcessor(); gameService.changeScene(MenuScene.class); } }); return layer; }
public void initGroup() { // TODO Auto-generated method stub setWidth(Constant.MAP_UNIT_SIZE_WIDTH * 2); setHeight(Constant.MAP_UNIT_SIZE_HEIGHT); switch (id + 1) { case 1: tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]); range = Constant.TOWER_1_RANGE; break; case 2: tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]); range = Constant.TOWER_2_RANGE; break; case 3: tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]); range = Constant.TOWER_3_RANGE; break; case 4: tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]); range = Constant.TOWER_4_RANGE; break; case 5: tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]); range = Constant.TOWER_5_RANGE; break; case 6: tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]); range = Constant.TOWER_6_RANGE; break; case 7: tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]); range = Constant.TOWER_7_RANGE; break; case 8: tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]); range = Constant.TOWER_8_RANGE; break; case 9: tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]); range = Constant.TOWER_9_RANGE; break; case 10: tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]); range = Constant.TOWER_10_RANGE; break; default: break; } tower.setPosition(Constant.MAP_UNIT_SIZE_WIDTH / 2 - tower.getWidth() / 2, 0); addActor(tower); ok = new Image(Assets.shared().button_ok); ok.setWidth(Constant.MAP_UNIT_SIZE_WIDTH); ok.setHeight(Constant.MAP_UNIT_SIZE_HEIGHT); ok.setColor(Color.GREEN); ok.setPosition(getWidth() / 2, 0); addActor(ok); ok_press = new Image(Assets.shared().button_ok_click); ok_press.setWidth(Constant.MAP_UNIT_SIZE_WIDTH); ok_press.setHeight(Constant.MAP_UNIT_SIZE_HEIGHT); ok_press.setColor(Color.GREEN); ok_press.setPosition(getWidth() / 2, 0); ok_press.setVisible(false); addActor(ok_press); ok.addListener( new ClickListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { // TODO Auto-generated method stub if (screen.world.getTowerCoin(id + 1) <= screen.world.coin) { screen.world.coin -= screen.world.getTowerCoin(id + 1); screen.world.addNewTower(id + 1, screen.pos, 4); for (int i = 0; i < screen.towerButton.length; i++) { if (screen.towerButton[i].getX() == getX() && screen.towerButton[i].getY() == getY()) { screen.towerButton[i].isVisible = false; } } for (int j = 0; j < screen.world.activeTower.size; j++) { if ((screen.world.activeTower.get(j).getPosition().x - screen.world.activeTower.get(j).xPlus) == getX() && (screen.world.activeTower.get(j).getPosition().y - screen.world.activeTower.get(j).yPlus) == getY()) { screen.radar = true; screen.towerPos = j; break; } } setVisible(false); screen.towerGroup.setVisible(false); } else { // not enough gold screen.dialog.setInfo(Constant.not_money_enough); screen.dialog.setVisible(true); } ok.setVisible(true); ok_press.setVisible(false); super.touchUp(event, x, y, pointer, button); } @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { // TODO Auto-generated method stub ok.setVisible(false); ok_press.setVisible(true); return super.touchDown(event, x, y, pointer, button); } }); }
private void rebuildStage() { buttonPause = new JellyButton(Assets.instance.gameElements.pause); buttonPause.setMyScaleSize(1.3f, 1.3f); buttonPause.setPosition(8, Const.GAME_HEIGHT - buttonPause.getHeight() - 8); buttonPause.addTouchListener( new RunnableAction() { public void run() { pauseUi.showWindow(true); } }, null); buttonReplay = new JellyButton(Assets.instance.gameElements.replay); buttonReplay.setMyScaleSize(1.3f, 1.3f); buttonReplay.setPosition(8, Const.GAME_HEIGHT - 2 * buttonReplay.getHeight() - 15); buttonReplay.addTouchListener( new RunnableAction() { public void run() { winnerUi.showWindow(true); winnerUi.setTime(110); } }, null); Label.LabelStyle labelStyle = new Label.LabelStyle(Assets.instance.fonts.freezers, Color.WHITE); gameTime = new Label("0:00", labelStyle); gameTime.setAlignment(Align.left); gameTime.setPosition(Const.GAME_WIDTH - 135, Const.GAME_HEIGHT - 60); gameTime.setWrap(true); gameTime.setWidth(350f); star = new Image(Assets.instance.gameElements.star); star.setScale(0.3f); star.setOrigin(star.getWidth() / 2, star.getHeight() / 2); star.addAction(Actions.alpha(0f)); star1 = new Image(Assets.instance.gameElements.star); star1.setScale(0.3f); star1.setPosition(Const.GAME_WIDTH - 60, Const.GAME_HEIGHT - 92); star2 = new Image(Assets.instance.gameElements.star); star2.setScale(0.3f); star2.setPosition(star1.getX() - 40, Const.GAME_HEIGHT - 92); star3 = new Image(Assets.instance.gameElements.star); star3.setScale(0.3f); star3.setPosition(star2.getX() - 40, Const.GAME_HEIGHT - 92); Label.LabelStyle labelStyle2 = new Label.LabelStyle(Assets.instance.fonts.freezers, Color.WHITE); freezes = new Label("0", labelStyle2); freezes.setText(String.valueOf(LevelData.freezers)); freezes.setAlignment(Align.right); freezes.setPosition(Const.GAME_WIDTH - 200, Const.GAME_HEIGHT - 170); freezes.setWrap(true); freezes.setWidth(100f); freezeFon = new Image(Assets.instance.gameElements.freezeBuyFon); freezeFon.setPosition( Const.GAME_WIDTH - 158, Const.GAME_HEIGHT - buttonReplay.getHeight() - 107); freezeFon.setScale(0.6f); buttonBuyFreeze = new JellyButton(Assets.instance.gameElements.freezeBuy); buttonBuyFreeze.setMyScaleSize(1.6f, 1.6f); buttonBuyFreeze.setPosition( Const.GAME_WIDTH - buttonBuyFreeze.getWidth() - 15, Const.GAME_HEIGHT - buttonReplay.getHeight() - 100); buttonBuyFreeze.addTouchListener( new RunnableAction() { public void run() { marketUi.showWindow(true); } }, null); imgFreeze = new Image(Assets.instance.gameElements.freeze); imgFreeze.setOrigin(imgFreeze.getWidth() / 2, imgFreeze.getHeight() / 2); imgFreeze.setScale(0.7f); imgFreeze.setPosition(freezeFon.getX() - 17, freezeFon.getY() - 25); imgFreeze.addAction(Actions.alpha(0f)); if (addHelp) { float delay = 5f; if (GamePreferences.instance.isSensorXYZ) { delay = 4f; helpNavigate = new Image(Assets.instance.menuElements.navigate_tel); helpNavigate.setOrigin(helpNavigate.getWidth() / 2, helpNavigate.getHeight() / 2); helpNavigate.setScale(0.7f); helpNavigate.setPosition( Const.GAME_WIDTH - helpNavigate.getWidth() - 25, Const.GAME_HEIGHT - 500); helpNavigate.addAction( sequence( Actions.alpha(0f), Actions.delay(2f), new RunnableAction() { public void run() { gameState = GameState.PAUSE; } }, Actions.alpha(1f, 0.5f), Actions.rotateBy(15f, 0.4f, Interpolation.fade), Actions.rotateBy(-30f, 0.8f, Interpolation.fade), Actions.rotateBy(25f, 0.7f, Interpolation.fade), Actions.alpha(0f, 0.4f))); } else { helpNavigate = new Image(Assets.instance.menuElements.navigate_finger); helpNavigate.setOrigin(helpNavigate.getWidth() / 2, helpNavigate.getHeight() / 2); helpNavigate.setScale(0.7f); helpNavigate.setPosition( Const.GAME_WIDTH - helpNavigate.getWidth() - 25, Const.GAME_HEIGHT - 500); helpNavigate.addAction( sequence( Actions.alpha(0f), Actions.delay(2f), new RunnableAction() { public void run() { gameState = GameState.PAUSE; } }, Actions.alpha(1f, 0.5f), Actions.moveBy(-150f, 0, 0.7f, Interpolation.fade), Actions.moveBy(80f, 0, 0.7f, Interpolation.fade), Actions.moveBy(0, 150f, 0.7f, Interpolation.fade), Actions.moveBy(0, -200f, 0.7f, Interpolation.linear), Actions.alpha(0f, 0.4f))); } helpFreeze = new Image(Assets.instance.menuElements.navigate_finger); helpFreeze.setOrigin(helpFreeze.getWidth() / 2, helpFreeze.getHeight() / 2); helpFreeze.setScale(-0.7f, 0.7f); helpFreeze.setPosition(helpFreeze.getWidth() + 35, Const.GAME_HEIGHT - 500); helpFreeze.addAction( sequence( Actions.alpha(0f), Actions.delay(delay), Actions.alpha(1f, 0.5f), Actions.moveBy( LevelData.posX - helpFreeze.getX() + 20, LevelData.posY - helpFreeze.getY() - helpFreeze.getHeight() - 28, 0.7f, Interpolation.fade), new RunnableAction() { public void run() { setAnimation(animFreezeOn); } }, Actions.alpha(0f, 0.2f))); } if (addHelp) { stage.addActor(helpNavigate); stage.addActor(helpFreeze); } stage.addActor(buttonPause); stage.addActor(buttonReplay); stage.addActor(gameTime); stage.addActor(freezeFon); stage.addActor(freezes); stage.addActor(buttonBuyFreeze); stage.addActor(star1); stage.addActor(star2); stage.addActor(star3); stage.addActor(star); stage.addActor(imgFreeze); stage.addActor(levelBuilder); stage.addActor(winnerUi); stage.addActor(marketUi); stage.addActor(pauseUi); }
// Metodo que acomoda las imagenes hacia el centro de la pantalla private void CenterImgActorToScreen(Image act) { int actPosX = Gdx.graphics.getWidth() / 2 - (int) act.getWidth() / 2; int actPosY = Gdx.graphics.getHeight() / 2 - (int) act.getHeight() / 2; act.setPosition(actPosX, actPosY); }