Пример #1
0
  private void atualizarLabels() {
    float x = camera.viewportWidth / 2 - lbTitulo.getPrefWidth() / 2;
    float y = camera.viewportHeight - 100;
    lbTitulo.setPosition(x, y);

    x = camera.viewportWidth / 2 - lbPontuacao.getPrefWidth() / 2;
    y = 100;
    lbPontuacao.setPosition(x, y);
  }
Пример #2
0
 @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());
 }
Пример #3
0
  @Override
  public void show() {
    super.show();

    gameTimeLabel.setPosition(
        SCREEN_WIDTH / 2 - (gameTimeLabel.getPrefWidth() / 2), SCREEN_HEIGHT * 0.8f);
    uiStage.addActor(gameTimeLabel);

    infoLabel.setPosition(SCREEN_WIDTH / 2 - (infoLabel.getPrefWidth() / 2), SCREEN_HEIGHT * 0.5f);
    infoLabel.setVisible(false);
    uiStage.addActor(infoLabel);

    Gdx.input.setInputProcessor(game);
  }
Пример #4
0
  @Override
  public void show() {
    super.show();

    // Game-Labels initialisieren
    timeLabel.setFontScale(0.5f);
    timeLabel.setPosition(
        SCREEN_WIDTH - (timeLabel.getPrefWidth() * 3), SCREEN_HEIGHT - timeLabel.getPrefHeight());
    uiStage.addActor(timeLabel);

    livesLabel.setFontScale(0.5f);
    livesLabel.setPosition(
        SCREEN_WIDTH - (timeLabel.getPrefWidth() * 4) - livesLabel.getPrefWidth(),
        SCREEN_HEIGHT - livesLabel.getPrefHeight());
    uiStage.addActor(livesLabel);
  }
Пример #5
0
 public TextLabel(String title, Color color, BitmapFont font, int align) {
   style = new Label.LabelStyle(font, color);
   label = new Label(title, style);
   label.setAlignment(align);
   addActor(label);
   this.setSize(label.getPrefWidth(), label.getPrefHeight());
 }
Пример #6
0
 public TextLabel(String title, Color color) {
   style = new Label.LabelStyle(Assets.getInstance().getMidFont(), color);
   label = new Label(title, style);
   label.setAlignment(Align.center);
   addActor(label);
   this.setSize(label.getPrefWidth(), label.getPrefHeight());
 }
Пример #7
0
 @Override
 public void show() {
   Gdx.app.log(LOG, "Showing screen: " + getName());
   // FPS Label
   fpsLabel.setFontScale(0.5f);
   fpsLabel.setPosition(
       uiStage.getWidth() - fpsLabel.getPrefWidth(), uiStage.getHeight() - fpsLabel.getHeight());
   if (reaktio.getPreferencesManager().isFpsCounterEnabled()) uiStage.addActor(fpsLabel);
 }
Пример #8
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    camera.update();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();

    backgroundImage.draw(batch, 1);
    preUIrender(delta);

    batch.end();

    // Update FPS-Counter
    fpsLabel.setText("FPS: " + String.valueOf(Gdx.graphics.getFramesPerSecond()));
    fpsLabel.setPosition(
        uiStage.getWidth() - fpsLabel.getPrefWidth(),
        uiStage.getHeight() - fpsLabel.getPrefHeight() / 2);

    uiStage.act(delta);
    uiStage.draw();
  }
Пример #9
0
  @Override
  public void preUIrender(float delta) {
    // Game-Labels updaten
    timeLabel.setText("TIME: " + String.valueOf((System.currentTimeMillis() - startTime) / 1000));
    timeLabel.setPosition(0, uiStage.getHeight() - timeLabel.getPrefHeight() / 2);

    livesLabel.setText("LIVES: " + String.valueOf(player.getLives()));
    livesLabel.setPosition(
        (uiStage.getWidth() / 2) - (livesLabel.getPrefWidth() / 2),
        uiStage.getHeight() - timeLabel.getPrefHeight() / 2);

    // Kamera auf Spieler-X ausrichten, auf Map setzen und Map rendern
    float playerCenterPos = player.getX() + player.getEntityWidth() / 2;
    boolean playerOutLeft = playerCenterPos < (SCREEN_WIDTH / 2);
    boolean playerOutRight =
        playerCenterPos > (getMap().getMapWidthAsScreenUnits() - (SCREEN_WIDTH / 2));

    if (!playerOutLeft && !playerOutRight)
      camera.position.x = player.getX() + player.getEntityWidth() / 2;
    else {
      if (playerOutLeft) camera.position.x = SCREEN_WIDTH / 2;
      else camera.position.x = getMap().getMapWidthAsScreenUnits() - (SCREEN_WIDTH / 2);
    }
    camera.update();

    OrthogonalTiledMapRenderer renderer = map.getRenderer();
    renderer.setView(camera);
    renderer.render();

    renderer.getSpriteBatch().begin();

    // Spieler rendern
    player.render(renderer.getSpriteBatch());

    for (AbstractEntity enemy : entityList) {
      // Position des Players:
      float playerWidthPosXLeft = player.getX();
      float playerHeightPosLeft = player.getY();
      // Position des Gegners:
      float enemyWidthPosXLeft = enemy.getX();
      float enemyHeightPosYLeft = enemy.getY();
      // Initialisierung der Spieler-Box und Gegner-Box
      PlayerBox =
          new Rectangle(
              playerWidthPosXLeft, playerHeightPosLeft, player.getWidth(), player.getHeight());
      EnemyBox =
          new Rectangle(
              enemyWidthPosXLeft, enemyHeightPosYLeft, enemy.getWidth(), enemy.getHeight());

      // Gegner rendern
      enemy.render(renderer.getSpriteBatch());

      // Kollisionsfunktion zwischen dem Spieler und Gegnern
      BoxCollides(PlayerBox, EnemyBox);
    }

    // Entitys rendern
    for (AbstractEntity entity : poolableEntityList) entity.render(renderer.getSpriteBatch());

    renderer.getSpriteBatch().end();
  }
Пример #10
0
 public void setText(String text) {
   label.setText(text);
   this.setSize(label.getPrefWidth(), label.getPrefHeight());
 }
Пример #11
0
 /** Helper method for centering the progress label when it changes text. */
 private void centerProgressLabel() {
   progressLabel.setX(getWidth() / 2 - progressLabel.getPrefWidth() / 2);
 }
Пример #12
0
 @Override
 public float getPrefWidth() {
   return label.getPrefWidth() + style.pad * 2;
 }