public SplashScreen(TestGame pGame) {
    game = pGame;

    tree =
        new Texture(
            Gdx.files.internal(
                "graphics/tree.png")); // http://openclipart.org/detail/1936/tree-by-harmonic
    christmasTree = new TextureRegion(tree, 0, 0, 450, 730);
    ball =
        new Texture(
            Gdx.files.internal(
                "graphics/ball.png")); // http://openclipart.org/detail/170738/decorative-ball-by-merlin2525-170738
    snow =
        new Texture(
            Gdx.files.internal(
                "graphics/snow.png")); // http://openclipart.org/detail/170738/decorative-ball-by-merlin2525-170738

    font = new BitmapFont(Gdx.files.internal("ui/test.fnt"), false);

    stage = new Stage();

    // our christmas tree
    Image ctree = new Image(christmasTree);
    ctree.setSize(296, 480); // scale the tree to the right size
    ctree.setPosition(-300, 0);
    ctree.addAction(moveTo(400 - 148, 0, 1f));
    ctree.setZIndex(0);
    stage.addActor(ctree);

    Image ballImage = new Image(ball);
    ballImage.setPosition(400 - 148 + 60, 170);

    ballImage.setOrigin(32, 32);
    ballImage.setColor(1, 1, 1, 0);
    ballImage.addAction(
        sequence(
            delay(1),
            parallel(fadeIn(1), rotateBy(360, 1)),
            delay(2f),
            new Action() {
              // custom action to switch to the menu screen
              @Override
              public boolean act(float delta) {
                game.setScreen(new MenuScreen(game));
                return false;
              }
            }));

    stage.addActor(ballImage);

    // create the snowflakes
    for (int i = 0; i < 10; i++) {
      spawnSnowflake();
    }
  }
Exemple #2
0
  public GameOverScreen(Start game, int score) {

    line = "";

    // get previous file contents
    try {
      Scanner scanner = new Scanner(new FileReader("scores.txt"));
      while (scanner.hasNextLine()) {
        line += scanner.nextLine() + "\n";
      }

      scanner.close();
    } catch (FileNotFoundException e) {
      // file not found
    }

    // add new content
    try {

      String content = line + Integer.toString(score);

      File file = new File("scores.txt");

      if (!file.exists()) {
        file.createNewFile();
      }

      FileWriter fw = new FileWriter(file.getAbsoluteFile());
      BufferedWriter bw = new BufferedWriter(fw);
      bw.write(content);
      bw.close();

    } catch (IOException e) {
      // no line found
    }

    gameScreen = new GameScreen(game, updateHighScore());
    introScreen = new IntroScreen(game);

    this.game = game;
    stage = new Stage();
    batch = new SpriteBatch();

    gameOverTexture = new Texture("gameOver.png");
    playAgainTexture = new Texture("playAgain.png");
    gameOver = new Image(gameOverTexture);
    playAgain = new Image(playAgainTexture);

    gameOver.setPosition(Gdx.graphics.getWidth() / 10, Gdx.graphics.getHeight() / 10);
    playAgain.setPosition(Gdx.graphics.getWidth() / 10, -Gdx.graphics.getHeight() / 2);

    first = true;
  }
Exemple #3
0
  @Override
  public void onUse() {
    if (GemLord.getInstance().gameScreen.getBoard().getBoardState() != Board.BoardState.STATE_IDLE)
      return;
    if (!GemLord.getInstance().gameScreen.getBoard().isPlayerTurn()) return;

    if (currentCooldown <= 0) {
      GemLord.soundPlayer.playBow();
      int damage = random.nextInt(((35 - 20) + 1));
      damage += 20;

      Damage dmg = new Damage();
      dmg.damage = damage;
      GemLord.getInstance().gameScreen.getBoard().getEnemy().damage(dmg);
      addAction(Actions.sequence(Actions.scaleTo(2f, 2f, 0.15f), Actions.scaleTo(1f, 1f, 0.15f)));
      currentCooldown = cooldown;
      TextureAtlas atlas = GemLord.assets.get("data/textures/pack.atlas", TextureAtlas.class);
      Image projectile = new Image(atlas.findRegion("itemarrow"));
      projectile.setPosition(getX(), getY());

      float targetX = GemLord.getInstance().gameScreen.getBoard().getEnemy().getImage().getX();
      float targetY = GemLord.getInstance().gameScreen.getBoard().getEnemy().getImage().getY();

      projectile.addAction(
          Actions.sequence(
              Actions.moveTo(targetX, targetY, 0.25f),
              Actions.fadeOut(0.25f),
              Actions.removeActor()));

      GemLord.getInstance().gameScreen.getBoard().getEffectGroup().addActor(projectile);
    }
  }
  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);
  }
  @Override
  public void create() {
    FileHandle fh = Gdx.files.internal("freud.txt");
    TextureAtlas atlas = new TextureAtlas(fh);
    stage = new Stage();

    // ======= フロイト ==========
    TextureAtlas.AtlasRegion fruedRegion = atlas.findRegion("nigaoe_freud");
    // Imageクラスにregionを食わせるらしい
    Image fruedImage = new Image(fruedRegion);
    fruedImage.setPosition(0, 0);

    // ステージにActorを突っ込む
    // Imageはextends Widget。
    // Widgetはextends Actor implementes Layout
    stage.addActor(fruedImage); // stageの直下に追加

    // ======= 始皇帝 ==========
    TextureAtlas.AtlasRegion shikouteiRegion = atlas.findRegion("nigaoe_shikoutei");
    Image shikouteiImage = new Image(shikouteiRegion);
    shikouteiImage.setPosition(200, 0);
    stage.addActor(shikouteiImage); // stageの直下に追加

    // グループを生成する
    // Groupもextends Actor implemnts Cullable
    // Cullableはよく分からん
    // 多分Groupのabilityなんだと思うんだが
    // 親子関係の描画操作かな
    Group group = new Group();
    group.setPosition(150, 200);
    group.setScale(0.5f);
    stage.addActor(group);

    // ======= 正岡子規 ==========
    TextureAtlas.AtlasRegion masaokaRegion = atlas.findRegion("nigaoe_masaoka_shiki");
    Image masaokaImage = new Image(masaokaRegion);
    masaokaImage.setPosition(0, 0);
    group.addActor(masaokaImage); // groupの下に追加

    // ======= 石川ゴエモン ==========
    TextureAtlas.AtlasRegion goemonRegion = atlas.findRegion("nigaoe_ishikawa_goemon");
    Image goemonImage = new Image(goemonRegion);
    goemonImage.setPosition(200, 0);
    group.addActor(goemonImage); // groupの下に追加
  }
 @Override
 public void layout() {
   image.setPosition(0, 0);
   image.setSize(64, 64);
   txtName.setPosition(64, getPrefHeight() - txtName.getPrefHeight() - 5);
   txtName.setSize(txtName.getPrefWidth(), txtName.getPrefHeight());
   txtSoul.setPosition(64, txtName.getY() - txtSoul.getPrefHeight() + 5);
   txtSoul.setSize(txtSoul.getPrefWidth(), txtSoul.getPrefHeight());
 }
  public void addToStage(Stage stage, int x, int y, int width, int height) {

    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;

    System.out.println("Drawn at " + x + " " + y + " Dimensions " + width + " " + height);

    Texture texture = new Texture(Gdx.files.internal("Fuego_Back.png"));
    frontImage = new Image(texture);
    frontImage.setSize(width, height);
    frontImage.setPosition(x, y);

    backImage.setPosition(x, y);
    backImage.setSize(Gdx.graphics.getWidth() / 2, Gdx.graphics.getWidth() / 2 * 4 / 3);
    backImage.addAction(Actions.scaleTo(0, 1));
    stage.addActor(frontImage);
    stage.addActor(backImage);
  }
Exemple #8
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);
  }
 private void dropStar(Image img) {
   stars--;
   img.setDrawable(new TextureRegionDrawable(Assets.instance.gameElements.starOff));
   star.setPosition(img.getX() - 45, img.getY() - 50);
   star.addAction(
       Actions.sequence(
           Actions.scaleTo(0.3f, 0.3f),
           Actions.alpha(1f),
           Actions.parallel(
               Actions.rotateBy(210f, 0.9f),
               Actions.scaleTo(0.8f, 0.8f, 0.9f),
               Actions.moveTo(star.getX() - 45f, star.getY() - 210f, 1.2f),
               Actions.alpha(0f, 0.9f, Interpolation.circleIn))));
 }
Exemple #10
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);
  }
  @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);
  }
  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);
 }
Exemple #15
0
  private void popButtons() {
    // TODO Auto-generated method stub
    final TextButton btnOpt = new TextButton("Options", StylesManager.btnGray);
    final TextButton btnCloud = new TextButton("Cloud", StylesManager.btnGray);
    final TextButton btnPlay = new TextButton("Play", StylesManager.btnBlue);
    final TextButton btnSur = new TextButton("Survival", StylesManager.btnGreen);
    final TextButton btnCamp = new TextButton("Campaign", StylesManager.btnGreen);
    final Image imgCloud = new Image(Textures.cloud);
    imgCloud.setPosition(570, -140);

    // game modes btns

    btnSur.setBounds(250, 180, 150, 35);
    btnSur.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {

            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (x < btnSur.getWidth() && x > 0 && y < btnSur.getHeight() && y > 0) {
              maingame.setScreen(
                  maingame.questsScreen.generateScreen(
                      maingame.constDump.Survival(maingame.constDump.Home())));
              btnSur.addAction(Actions.fadeOut(1));
              btnCamp.addAction(Actions.fadeOut(1));
              btnPlay.setVisible(true);
              btnPlay.addAction(Actions.fadeIn(1));
            }
          }
        });
    btnSur.getColor().a = 0;
    table.addActor(btnSur);

    btnCamp.setBounds(410, 180, 150, 35);
    btnCamp.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {

            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (x < btnCamp.getWidth() && x > 0 && y < btnCamp.getHeight() && y > 0) {
              maingame.setScreen(maingame.questsScreen);

              btnSur.addAction(Actions.fadeOut(1));
              btnCamp.addAction(Actions.fadeOut(1));
              btnPlay.setVisible(true);
              btnPlay.addAction(Actions.fadeIn(1));
            }
          }
        });
    btnCamp.getColor().a = 0;
    table.addActor(btnCamp);

    // other btns
    btnOpt.setBounds(330, 130, 150, 35);
    btnOpt.getColor().a = 0.8f;
    btnOpt.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {

            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (x < btnOpt.getWidth() && x > 0 && y < btnOpt.getHeight() && y > 0) {
              btnSur.addAction(Actions.fadeOut(1));
              btnCamp.addAction(Actions.fadeOut(1));
              btnPlay.setVisible(true);
              btnPlay.addAction(Actions.fadeIn(1));
            }
          }
        });

    table.addActor(btnOpt);

    btnCloud.setBounds(650, 20, 90, 30);
    btnCloud.getColor().a = 0.7f;
    btnCloud.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {

            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (x < btnCloud.getWidth() && x > 0 && y < btnCloud.getHeight() && y > 0) {
              btnSur.addAction(Actions.fadeOut(1));
              btnCamp.addAction(Actions.fadeOut(1));
              btnPlay.setVisible(true);
              btnPlay.addAction(Actions.fadeIn(1));

              SequenceAction img_action = new SequenceAction();
              img_action.addAction(Actions.moveTo(570, -40, 1, Interpolation.linear));
              img_action.addAction(Actions.delay(0.2f));
              img_action.addAction(Actions.moveTo(570, -140, 1, Interpolation.linear));

              imgCloud.addAction(img_action);
            }
          }
        });

    table.addActor(imgCloud);
    table.addActor(btnCloud);

    btnPlay.setBounds(155 * 2 + 20, 180, 150, 35);
    btnPlay.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {

            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (x < btnPlay.getWidth() && x > 0 && y < btnPlay.getHeight() && y > 0) {
              btnSur.addAction(Actions.fadeIn(1));
              btnCamp.addAction(Actions.fadeIn(1));
              btnPlay.addAction(Actions.fadeOut(1));
              btnPlay.setVisible(false);
            }
          }
        });

    table.addActor(btnPlay);
  }
Exemple #16
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;
  }
Exemple #17
0
 @Override
 public void setPosition(float x, float y) {
   super.setPosition(x, y);
   position.set(x, y);
 }
Exemple #18
0
  @Override
  public void create() {
    texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);

    stage = new Stage();

    float loc = (NUM_SPRITES * (32 + SPACING) - SPACING) / 2;
    for (int i = 0; i < NUM_GROUPS; i++) {
      Group group = new Group();
      group.setX((float) Math.random() * (stage.getWidth() - NUM_SPRITES * (32 + SPACING)));
      group.setY((float) Math.random() * (stage.getHeight() - NUM_SPRITES * (32 + SPACING)));
      group.setOrigin(loc, loc);

      fillGroup(group, texture);
      stage.addActor(group);
    }

    uiTexture = new Texture(Gdx.files.internal("data/ui.png"));
    uiTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    ui = new Stage();

    Image blend = new Image(new TextureRegion(uiTexture, 0, 0, 64, 32));
    blend.setAlign(Align.center);
    blend.setScaling(Scaling.none);
    blend.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (stage.getSpriteBatch().isBlendingEnabled())
              stage.getSpriteBatch().disableBlending();
            else stage.getSpriteBatch().enableBlending();
            return true;
          }
        });
    blend.setY(ui.getHeight() - 64);

    Image rotate = new Image(new TextureRegion(uiTexture, 64, 0, 64, 32));
    rotate.setAlign(Align.center);
    rotate.setScaling(Scaling.none);
    rotate.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            rotateSprites = !rotateSprites;
            return true;
          }
        });
    rotate.setPosition(64, blend.getY());

    Image scale = new Image(new TextureRegion(uiTexture, 64, 32, 64, 32));
    scale.setAlign(Align.center);
    scale.setScaling(Scaling.none);
    scale.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            scaleSprites = !scaleSprites;
            return true;
          }
        });
    scale.setPosition(128, blend.getY());

    ui.addActor(blend);
    ui.addActor(rotate);
    ui.addActor(scale);

    fps = new Label("fps: 0", new Label.LabelStyle(font, Color.WHITE));
    fps.setPosition(10, 30);
    fps.setColor(0, 1, 0, 1);
    ui.addActor(fps);

    renderer = new ShapeRenderer();
    Gdx.input.setInputProcessor(this);
  }
Exemple #19
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);
  }