public void spawnSnowflake() {
    final Image snowflake = new Image(snow);
    snowflake.setOrigin(64, 64);
    int x = (int) (Math.random() * 800);
    snowflake.setPosition(x, 480);
    snowflake.setScale((float) (Math.random() * 0.8f + 0.2f));
    snowflake.addAction(
        parallel(
            forever(rotateBy(360, (float) (Math.random() * 6))),
            sequence(
                moveTo(x, 0, (float) (Math.random() * 15)),
                fadeOut((float) (Math.random() * 1)),
                new Action() { // we
                  // can
                  // define
                  // custom
                  // actions
                  // :)

                  @Override
                  public boolean act(float delta) {
                    snowflake.remove(); // delete this snowflake
                    spawnSnowflake(); // spawn a new snowflake
                    return false;
                  }
                })));
    stage.addActor(snowflake);
  }
Exemple #2
0
 private Table buildBackgoundLayer() {
   Table layer = new Table();
   imgBackgound = new Image(skinCanyonBunny, "map");
   imgBackgound.setScale(Constants.SCALE);
   layer.add(imgBackgound);
   imgBackgound.setColor(
       imgBackgound.getColor().r, imgBackgound.getColor().g, imgBackgound.getColor().b, 0.2f);
   return layer;
 }
Exemple #3
0
  @Override
  public void render() {
    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (Gdx.input.isTouched()) {
      stage.screenToStageCoordinates(stageCoords.set(Gdx.input.getX(), Gdx.input.getY()));
      Actor actor = stage.hit(stageCoords.x, stageCoords.y, true);
      if (actor instanceof Image)
        ((Image) actor)
            .setColor(
                (float) Math.random(),
                (float) Math.random(),
                (float) Math.random(),
                0.5f + 0.5f * (float) Math.random());
    }

    Array<Actor> actors = stage.getActors();
    int len = actors.size;
    if (rotateSprites) {
      for (int i = 0; i < len; i++) actors.get(i).rotateBy(Gdx.graphics.getDeltaTime() * 10);
    }

    scale += vScale * Gdx.graphics.getDeltaTime();
    if (scale > 1) {
      scale = 1;
      vScale = -vScale;
    }
    if (scale < 0.5f) {
      scale = 0.5f;
      vScale = -vScale;
    }

    len = images.size();
    for (int i = 0; i < len; i++) {
      Image img = images.get(i);
      if (rotateSprites) img.rotateBy(-40 * Gdx.graphics.getDeltaTime());
      else img.setRotation(0);

      if (scaleSprites) {
        img.setScale(scale);
      } else {
        img.setScale(1);
      }
      img.invalidate();
    }

    stage.draw();

    renderer.begin(ShapeType.Point);
    renderer.setColor(1, 0, 0, 1);
    len = actors.size;
    for (int i = 0; i < len; i++) {
      Group group = (Group) actors.get(i);
      renderer.point(group.getX() + group.getOriginX(), group.getY() + group.getOriginY(), 0);
    }
    renderer.end();

    fps.setText(
        "fps: "
            + Gdx.graphics.getFramesPerSecond()
            + ", actors "
            + images.size()
            + ", groups "
            + actors.size);
    ui.draw();
  }
  public Button getLevelButton(int level) {
    Button button = new Button(skin);
    ButtonStyle style = button.getStyle();
    style.up = style.down = null;

    starTable = new Table();
    starTable.defaults().pad(2);
    // System.out.println("here");

    Label label = new Label(Integer.toString(level), skin);
    label.setFontScale(1f);
    label.setAlignment(Align.center);

    Label label2 = new Label("", skin);
    label2.setFontScale(1f);
    label2.setAlignment(Align.center);

    Label labelLocked = new Label("", skin);
    label2.setFontScale(1f);
    label2.setAlignment(Align.center);

    Label starsLabel = new Label("stadfrs", skin, "big-font");

    starsLabel.setFontScale(0.3f);
    // starsLabel.setPosition(12, -5);
    starsLabel.setAlignment(Align.bottom, Align.center);

    TextureRegion crystal;
    Texture tex = new Texture(Gdx.files.internal("images/hud.png"));

    crystal = new TextureRegion(tex, 80, 0, 16, 16);
    Image img = new Image(crystal);
    img.setScale(0.5f);
    // Stack the image and the label at the top of our button

    switch (level) {
      case 1:
        Table table = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelOneHighScore() + " / " + 30);
        table.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table.add(img).padBottom(-29).padLeft(4).bottom();
        // starsLabel.setPosition(100, 100);
        button.stack(new Image(skin.getDrawable("top")), label, table).expand().fill();
        game.manager.load("images/ropes.png", Texture.class);
        break;
      case 2:
        Table table2 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelTwoHighScore() + " / " + 30);
        table2.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table2.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel1 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table2)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table2).expand().fill();
        }
        break;
      case 3:
        Table table3 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelThreeHighScore() + " / " + 30);
        table3.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table3.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel2 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table3)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table3).expand().fill();
        }
        break;
      case 4:
        Table table4 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelFourHighScore() + " / " + 30);
        table4.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table4.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel3 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table4)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table4).expand().fill();
        }
        break;
      case 5:
        Table table5 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelFiveHighScore() + " / " + 35);
        table5.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table5.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel4 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table5)
              .expand()
              .fill();

        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table5).expand().fill();
        }
        break;
      case 6:
        Table table6 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelSixHighScore() + " / " + 35);
        table6.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table6.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel5 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table6)
              .expand()
              .fill();

        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table6).expand().fill();
        }
        break;
      case 7:
        Table table7 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelSevenHighScore() + " / " + 40);
        table7.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table7.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel6 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table7)
              .expand()
              .fill();

        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table7).expand().fill();
        }
        break;
      case 8:
        Table table8 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelEightHighScore() + " / " + 35);
        table8.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table8.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel7 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table8)
              .expand()
              .fill();

        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table8).expand().fill();
        }
        break;
      case 9:
        Table table9 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelNineHighScore() + " / " + 60);
        table9.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table9.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel8 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table9)
              .expand()
              .fill();
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table9).expand().fill();
        }
        break;
      case 10:
        Table table10 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelTenHighScore() + " / " + 30);
        table10.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table10.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel9 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table10)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table10).expand().fill();
        }
        break;
      case 11:
        Table table11 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelElevenHighScore() + " / " + 35);
        table11.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table11.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel10 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table11)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table11).expand().fill();
        }
        break;
      case 12:
        Table table12 = new Table();
        starsLabel.setText(game.getPreferencesManager().getLevelTwelveHighScore() + " / " + 30);
        table12.add(starsLabel).padBottom(-30).padLeft(6).bottom();
        table12.add(img).padBottom(-29).padLeft(4).bottom();
        if (starsLevel11 == 0) {
          button
              .stack(new Image(skin.getDrawable("lockedlevel")), labelLocked, table12)
              .expand()
              .fill();

          // button.add(starsLabel);
        } else {
          button.stack(new Image(skin.getDrawable("top")), label, table12).expand().fill();
        }
        break;
    }

    button.row();
    button.add(starTable).height(10);

    button.setName(Integer.toString(level));
    button.addListener(levelClickListener);

    int levelSel = Integer.parseInt(button.getName());

    switch (levelSel) {
      case 1:
        doStars(starsLevel1);
        break;
      case 2:
        doStars(starsLevel2);
        break;
      case 3:
        doStars(starsLevel3);
        break;
      case 4:
        doStars(starsLevel4);
        break;
      case 5:
        doStars(starsLevel5);
        break;
      case 6:
        doStars(starsLevel6);
        break;
      case 7:
        doStars(starsLevel7);
        break;
      case 8:
        doStars(starsLevel8);
        break;
      case 9:
        doStars(starsLevel9);
        break;
      case 10:
        doStars(starsLevel10);
        break;
      case 11:
        doStars(starsLevel11);
        break;
      case 12:
        doStars(starsLevel12);
        break;
      default:
        for (int star = 0; star < 3; star++) {
          if (-1 > star) {
            starTable.add(new Image(skin.getDrawable("star-filled"))).width(20).height(12);
          } else {
            starTable.add(new Image(skin.getDrawable("star-unfilled"))).width(20).height(12);
          }
        }
        break;
    }

    return button;
  }
Exemple #5
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;
  }
  @Override
  public void show() {
    super.show();

    backgroundStage.addActor(new Image(atlas.findRegion("background")));

    Image alien = new Image(atlas.findRegion("alien"));
    alien.setPosition(mainStage.getWidth() + mainStage.getPadLeft(), -365f);
    mainStage.addActor(alien);

    Image energy = new Image(atlas.findRegion("energy")); // 195, 313
    energy.setPosition(83f, 201f);
    energy.setScale(0f);
    energy.setOrigin(energy.getPrefWidth() / 2, energy.getPrefHeight() / 2);
    mainStage.addActor(energy);

    final Table certificateTable = new Table();
    certificateTable.padTop(314f).padBottom(101f).defaults().padBottom(100f);
    certificateTable.setBackground(new TextureRegionDrawable(atlas.findRegion("certificate")));
    certificateTable.setSize(mainStage.getWidth(), mainStage.getHeight());
    certificateTable.setOrigin(195f, 313f);
    certificateTable.setTransform(true);
    certificateTable.setTouchable(Touchable.disabled);
    certificateTable.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Assets.fanfareFX.stop();
            game.loadNextScreen(EndingScreen.this, KonnectingGame.ScreenType.MAIN_MENU);
          }
        });
    certificateTable.setScale(0f);
    mainStage.addActor(certificateTable);

    StatsData tempData = SavedData.getStats();
    int score =
        tempData.kronosScore1
            + tempData.kronosScore2
            + tempData.kronosScore3
            + tempData.kronosScore4
            + tempData.kronosScore5
            + tempData.kronosScore6
            + tempData.kronosScore7
            + tempData.zappingScore1
            + tempData.zappingScore2
            + tempData.zappingScore3
            + tempData.zappingScore4
            + tempData.zappingScore5;

    final Label userLabel =
        new Label(
            SavedData.getUsername() + "\n\n" + score + "pt",
            new Label.LabelStyle(uiSkin.getFont("default-font"), Color.WHITE));
    userLabel.setWrap(true);
    userLabel.setAlignment(Align.center);
    userLabel.getColor().a = 0f;
    certificateTable.add(userLabel).width(407f).row();

    String correctComment = comments[0];
    for (int i = scoreLimits.length - 1; i >= 0; i--) {
      if (score > scoreLimits[i]) {
        correctComment = comments[i];
        break;
      }
    }
    final Label commentLabel =
        new Label(correctComment, new Label.LabelStyle(uiSkin.getFont("arial"), Color.WHITE));
    commentLabel.setWrap(true);
    commentLabel.setFontScale(0.9f);
    commentLabel.setAlignment(Align.center);
    commentLabel.getColor().a = 0f;
    certificateTable.add(commentLabel).width(407f);

    Timeline.createSequence()
        .push(Tween.to(alien, ActorAccessor.MOVE_X, 1f).target(20f))
        .pushPause(0.25f)
        .push(Tween.to(energy, ActorAccessor.SCALEXY, 1f).target(1f))
        .push(Tween.to(energy, ActorAccessor.SCALEXY, 0.5f).target(0.8f))
        .push(Tween.to(energy, ActorAccessor.SCALEXY, 0.5f).target(1f))
        .push(Tween.to(certificateTable, ActorAccessor.SCALEXY, 0.5f).target(1f))
        .beginParallel()
        .push(Tween.to(userLabel, ActorAccessor.ALPHA, 0.5f).target(1f))
        .push(Tween.to(commentLabel, ActorAccessor.ALPHA, 0.5f).target(1f))
        .end()
        .setCallback(
            new TweenCallback() {
              @Override
              public void onEvent(int type, BaseTween<?> source) {
                Assets.fanfareFX.setOnCompletionListener(
                    new Music.OnCompletionListener() {
                      @Override
                      public void onCompletion(Music music) {
                        Assets.fanfareFX.setOnCompletionListener(null);
                        certificateTable.setTouchable(Touchable.enabled);
                      }
                    });
                Assets.fanfareFX.play();
              }
            })
        .start(tweenManager);
  }
  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);
  }
Exemple #8
0
  public HandGroup(GameEventNotifier notifier) {
    super(notifier);

    cards = new Group();
    cards.setBounds(0, 0, UIConstants.WORLD_WIDTH, UIConstants.WORLD_HEIGHT / 2);

    addActor(cards);

    // set up the images and buttons for the zoom menu
    selectButton = new Image(selectTexture);
    selectButton.setScale(1.5f);
    selectButton.setPosition(220, 700);
    cancelButton = new Image(cancelTexture);
    cancelButton.setScale(1.5f);
    cancelButton.setPosition(220, 100);
    cancelButton.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // return the zoomed card
            unzoom();
            return true;
          }
        });
    nextCardImage = new Image(arrowTexture);
    nextCardImage.setScale(2f);
    nextCardImage.setPosition(1200, 300);
    nextCardImage.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            changeZoomedCard(1);
            return true;
          }
        });

    previousCardImage = new Image(arrowTexture);
    previousCardImage.rotateBy(180);
    previousCardImage.setScale(2f);
    previousCardImage.setPosition(500, 400);
    previousCardImage.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            changeZoomedCard(-1);
            return true;
          }
        });
    rotateImage = new Image(rotateTexture);
    rotateImage.setScale(0.5f);
    rotateImage.setPosition(350, 500);
    rotateImage.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            zoomCard.rotate();
            return true;
          }
        });
    zoomGroup = new Group();
    zoomGroup.addActor(selectButton);
    zoomGroup.addActor(cancelButton);
    zoomGroup.addActor(nextCardImage);
    zoomGroup.addActor(previousCardImage);
    zoomGroup.addActor(rotateImage);
    zoomGroup.setTouchable(Touchable.disabled);
    zoomGroup.setVisible(false);

    addActor(zoomGroup);
  }