Example #1
0
  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);
  }
Example #2
0
  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);
  }
Example #3
0
  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);
  }
Example #4
0
  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;
  }
Example #5
0
  public void initView() {
    clear();
    float currPos = 0;
    for (int i = 0; i < tabs.size(); i++) {
      boolean isSelected = false;
      if (i == selectedTabIndex) isSelected = true;
      String imgName = "tab";
      if (isSelected) {
        imgName = "tabS";
      }
      Image img = new Image(s.textureManager.getEditorAsset(imgName));
      img.setX(currPos);
      img.setY(0);

      Label lbl = new Label(tabs.get(i), s.textureManager.editorSkin);
      lbl.setX(currPos + 6);
      lbl.setY(2);
      lbl.setTouchable(Touchable.disabled);

      img.setScaleX(lbl.getWidth() + 12);
      currPos += lbl.getWidth() + 12;

      addActor(img);
      addActor(lbl);

      Image sep = new Image(s.textureManager.getEditorAsset("tabSep"));
      sep.setX(img.getX() + img.getScaleX());
      addActor(sep);
      currPos += 1;

      if (isSelected) {
        lbl.setColor(1, 1, 1, 1);
      } else {
        lbl.setColor(1, 1, 1, 0.65f);
      }

      final int currIndex = i;

      img.addListener(
          new ClickListener() {
            public void clicked(InputEvent event, float x, float y) {
              selectedTabIndex = currIndex;
              initView();
              if (tabEventListener != null) {
                tabEventListener.tabOpened(currIndex);
              }
            }
          });

      setHeight(img.getHeight());
    }

    float currWidth = currPos;
    if (getWidth() > currWidth) {
      float diff = getWidth() - currWidth;
      Image rest = new Image(s.textureManager.getEditorAsset("tab"));
      rest.setX(currPos);
      rest.setScaleX(diff);
      addActor(rest);
    }
  }
Example #6
0
  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;
  }
  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);
 }