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); }
/** * Creates a new LoadingScreenView. * * <p><b>Note:</b> This will load textures directly, and it is therefore important to remember to * dispose this view! */ public LoadingScreenView() { // Background screenBgTexture = new Texture(Gdx.files.internal("data/loadingScreenBg.png")); Image screenBg = new Image(screenBgTexture); screenBg.setFillParent(true); addActor(screenBg); // The loading bar background loadBarBgTexture = new Texture(Gdx.files.internal("data/loadingBarBg.png")); loadBarBgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); loadBarBg = new Image(loadBarBgTexture); loadBarBg.setY(LOAD_BAR_BOTTOM_MARGIN); loadBarBg.setWidth(LOAD_BAR_MAX_WIDTH); loadBarBg.setX(1280 / 2 - LOAD_BAR_MAX_WIDTH / 2); addActor(loadBarBg); // The loading bar loadBarTexture = new Texture(Gdx.files.internal("data/loadingBar.png")); loadBarTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); loadBar = new Image(loadBarTexture); loadBar.setY(LOAD_BAR_BOTTOM_MARGIN); loadBar.setX(loadBarBg.getX()); loadBar.setWidth(LOAD_BAR_MAX_WIDTH); addActor(loadBar); // Progress label progressLabelFont = new BitmapFont(Gdx.files.internal("data/fonts/arial_bold_32.fnt"), false); progressLabelFont .getRegion() .getTexture() .setFilter(TextureFilter.Linear, TextureFilter.Linear); LabelStyle ls = new LabelStyle(progressLabelFont, Color.BLACK); progressLabel = new Label("", ls); progressLabel.setY(65); addActor(progressLabel); }
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); } }); }