Ejemplo n.º 1
0
  public AotHudGameOver(Skin sk) {
    _skin = sk;
    Label gameover = new Label("GAME OVER", _skin.get("JUNEBUG_32", LabelStyle.class));
    _retry = new Label(">> RETRY <<", _skin.get("JUNEBUG_16", LabelStyle.class));
    _lvlselect = new Label(">> LEVEL SELECTION <<", _skin.get("JUNEBUG_16", LabelStyle.class));

    _retry.setPosition(0, 0);
    _lvlselect.setPosition(_retry.getWidth() + 100, 0);

    this.setWidth(_retry.getWidth() + _lvlselect.getWidth() + 100);

    gameover.setPosition((this.getWidth() - gameover.getWidth()) / 2, _retry.getHeight() + 100);

    this.setHeight(_retry.getHeight() + gameover.getHeight() + 100);

    addActor(gameover);
    addActor(_retry);
    addActor(_lvlselect);

    this.setPosition(
        (AbstractScreen.GAME_VIEWPORT_WIDTH - this.getWidth()) / 2,
        (AbstractScreen.MENU_VIEWPORT_HEIGHT - this.getHeight()) / 2 - 100);

    _lvlselect.addListener(this);
    _retry.addListener(this);
  }
Ejemplo n.º 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());
 }
Ejemplo n.º 3
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);
  }
Ejemplo n.º 4
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);
  }
    void render() {
      if (state != null && state.getCurrent(ui.trackButtons.getCheckedIndex()) == null) {
        ui.animationList.getSelection().setProgrammaticChangeEvents(false);
        ui.animationList.setSelected(null);
        ui.animationList.getSelection().setProgrammaticChangeEvents(true);
      }

      statusLabel.pack();
      if (minimizeButton.isChecked()) statusLabel.setPosition(10, 25, Align.bottom | Align.left);
      else statusLabel.setPosition(window.getWidth() + 6, 5, Align.bottom | Align.left);

      stage.act();
      stage.draw();
    }
Ejemplo n.º 6
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);
  }
Ejemplo n.º 7
0
  @Override
  public void render() {
    /// Clear everything first
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    gsm = super.gsm;
    Stage stage = new Stage();

    /// Create Skin
    createSkin();

    /// Create Title
    CharSequence charSeq;
    charSeq = "MANIC";
    Label title = new Label(charSeq, skin);
    title.setPosition(
        (float) (Gdx.graphics.getWidth() * .49 - Gdx.graphics.getWidth() * .125),
        (float) (Gdx.graphics.getHeight() * .70));
    title.setFontScale(4);

    /// Create Start Button
    TextButton startButton = new TextButton("Press Space to Start", skin);
    startButton.setPosition(
        Gdx.graphics.getWidth() / 2 - Gdx.graphics.getWidth() / 8, Gdx.graphics.getHeight() / 3);

    /// Add and draw
    stage.addActor(title);
    stage.addActor(startButton);
    stage.act();
    stage.draw();
  }
Ejemplo n.º 8
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);
 }
Ejemplo n.º 9
0
  public LabelText(String s, float x, float y) {
    labelStyle = new Label.LabelStyle();
    labelStyle.font = Fonts.GOST_28;
    levNumLabel = new Label(s, labelStyle);
    levNumLabel.setPosition(x / 2 - levNumLabel.getWidth() / 2, y - levNumLabel.getHeight() - 10);
    setOrigin(x / 2, y - levNumLabel.getHeight() / 2 - 10);

    addActor(levNumLabel);
  }
Ejemplo n.º 10
0
 public void showNotif(String text) {
   notifTxt.remove();
   notifTxt.setText(text);
   notifTxt.setPosition(512 - notifTxt.getWidth() / 2, 300 - notifTxt.getHeight() / 2);
   notifTxt.setAlignment(Align.center);
   GdxGame.ui_stage1.addActor(notifTxt);
   notifTxt.clearActions();
   notifTxt.addAction(sequence(alpha(1f), delay(1f), fadeOut(1f), removeActor()));
 }
Ejemplo n.º 11
0
 public void move(float x, float y) {
   position.x += x;
   position.y += y;
   Vector2 lPos =
       Utils.mapToScreen(
           new Vector2(position.x - 0.5F, position.y + 1),
           new Vector2(game.getMainCam().position.x, game.getMainCam().position.y));
   label.setPosition(lPos.x, lPos.y);
 }
  public MathsScreen(Game g) {
    game = g;
    stage = new Stage();
    Gdx.input.setInputProcessor(stage); // get input from our stage

    num1 = MathUtils.random(10, 100); // libgdx easy random numbers :)
    num2 = MathUtils.random(10, 100);
    ans = num1 * num2;

    Skin skin =
        new Skin(
            Gdx.files.internal(
                "uiskin.json")); // set what the UI elements are going to look like, libgdx provides
    // file abstraction to make it easy to access files on any platform

    question =
        new Label(
            "What is the area of a rectangle of   " + num1 + "    by    " + num2,
            skin); // Create a label element
    question.setPosition(100, 500); // Position it
    stage.addActor(question); // Add the lable to the stage

    answer = new TextField("", skin); // Create a textfield element
    answer.setPosition(300, 340); // Position it
    stage.addActor(answer); // Add it to the stage

    feedback = new Label("", skin); // Create a label element
    feedback.setPosition(300, 150); // Position it
    stage.addActor(feedback); // Add the lable to the stage

    check = new TextButton("Check your answer", skin);
    check.setPosition(300, 200);
    check.addListener(
        new ClickListener() // add the listener as an anonymous? method, inline method
        {
          // autocomplete the code below by typing clicked and then ctrl + space, modify to add our
          // own btClicked method
          public void clicked(InputEvent e, float x, float y) {
            btnClicked();
          }
        });
    stage.addActor(check);
  }
Ejemplo n.º 13
0
  private void layout() {
    lblMsg.setHeight(50);
    lblMsg.setWidth(w);
    lblMsg.setAlignment(Align.center, Align.center);
    lblMsg.setWrap(true);
    lblMsg.setText(Msg);
    lblMsg.setPosition(0, h - lblMsg.getHeight());

    if (WorkPathFound > 0) {
      btnRunTranslations.setVisible(true);
      if (ImageWorkPathFound) btnRunTexturePacker.setVisible(true);
      else btnRunTexturePacker.setVisible(false);

      btnRunLibGdx.setWidth(300);
      btnRunLibGdx.setHeight(35);
      btnRunLibGdx.setY(lblMsg.getY() - margin - btnRunLibGdx.getHeight());
      btnRunLibGdx.setX(margin);

      btnRunTranslations.setWidth(300);
      btnRunTranslations.setHeight(35);
      btnRunTranslations.setY(lblMsg.getY() - margin - btnRunLibGdx.getHeight());
      btnRunTranslations.setX(btnRunLibGdx.getX() + btnRunLibGdx.getWidth() + margin);

      btnRunTexturePacker.setWidth(300);
      btnRunTexturePacker.setHeight(35);
      btnRunTexturePacker.setY(lblMsg.getY() - margin - btnRunLibGdx.getHeight());
      btnRunTexturePacker.setX(btnRunTranslations.getX() + btnRunLibGdx.getWidth() + margin);

    } else {
      btnRunTranslations.setVisible(false);
      btnRunTexturePacker.setVisible(false);

      btnRunLibGdx.setWidth(300);
      btnRunLibGdx.setHeight(35);
      btnRunLibGdx.setY(lblMsg.getY() - margin - btnRunLibGdx.getHeight());
      btnRunLibGdx.setX(w / 2 - btnRunLibGdx.getWidth() / 2);
    }

    lblOut.setHeight(btnRunLibGdx.getY() - margin - margin);
    lblOut.setWidth(w - margin - margin);
    lblOut.setWrap(true);
    lblOut.setPosition(margin, margin);
  }
Ejemplo n.º 14
0
 public void addScore() {
   LabelStyle style = new LabelStyle();
   style.font =
       new BitmapFont(
           Gdx.files.internal("data/flappyfont.fnt"),
           Gdx.files.internal("data/flappyfont.png"),
           false);
   labelScore = new Label("0", style);
   labelScore.setPosition(
       Flappybird.VIEWPORT.x / 2 - labelScore.getWidth() / 2,
       Flappybird.VIEWPORT.y - labelScore.getHeight());
   stage.addActor(labelScore);
 }
Ejemplo n.º 15
0
  /**
   * Create a countdown in the screen lasting for the amount of seconds given. When the countdown
   * reaches 0, the code provided in the runnable will be executed as a callback.
   *
   * @param seconds how many seconds should the countdown be displayed.
   */
  private void countdown(final int seconds, final Runnable after) {
    // Since this is a recursive function, avoid the case where you pass
    // a number of seconds that might trigger an infinite loop.
    if (seconds <= 0) {
      return;
    }

    // Create the label that will contain this number
    String number = Integer.toString(seconds);
    final Label label = new Label(number, game.getSkin(), "monospace");
    label.setFontScale(5f);
    label.setSize(150, 150);
    label.setAlignment(Align.center);
    label.setPosition(
        (getStage().getWidth() - label.getWidth()) / 2,
        (getStage().getHeight() - label.getHeight()) / 2);

    // Add the label to the stage and play a sound to notify the user.
    getStage().addActor(label);
    game.player.playSound(SoundCode.SELECT);

    label.addAction(
        Actions.sequence(
            Actions.parallel(Actions.moveBy(0, 80, 1f)),

            // After the animation, decide. If the countdown hasn't finished
            // yet, run another countdown with 1 second less.
            Actions.run(
                new Runnable() {
                  @Override
                  public void run() {
                    label.remove();
                    if (seconds > 1) {
                      countdown(seconds - 1, after);
                    } else {
                      after.run();
                    }
                  }
                })));
  }
Ejemplo n.º 16
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();
  }
Ejemplo n.º 17
0
  private void showPartialScore(int score, Bounds bounds, boolean special) {
    // Calculate the center of the region.
    BallActor bottomLeftBall = board.getBall(bounds.minX, bounds.minY);
    BallActor upperRightBall = board.getBall(bounds.maxX, bounds.maxY);

    float minX = bottomLeftBall.getX();
    float maxX = upperRightBall.getX() + upperRightBall.getWidth();
    float minY = bottomLeftBall.getY();
    float maxY = upperRightBall.getY() + upperRightBall.getHeight();
    float centerX = (minX + maxX) / 2;
    float centerY = (minY + maxY) / 2;

    Label label = new Label("+" + score, game.getSkin(), "monospace");
    label.setFontScale(5f);
    label.setSize(140, 70);
    label.setAlignment(Align.center);
    label.setPosition(centerX - label.getWidth() / 2, centerY - label.getHeight() / 2);
    label.addAction(Actions.sequence(Actions.moveBy(0, 80, 0.5f), Actions.removeActor()));
    getStage().addActor(label);

    if (special) {
      label.setColor(Color.CYAN);
    }
  }
Ejemplo n.º 18
0
  @Override
  public void show() {
    // TODO Auto-generated method stub
    stage = new Stage();
    font = new BitmapFont(Gdx.files.internal("font.fnt"), false);
    style = new LabelStyle(font, Color.RED);
    label = new Label("Juego de Prueba", style);
    label.setPosition(Gdx.graphics.getWidth() / 3, Gdx.graphics.getHeight() - 100);
    stage.addActor(label);

    skin = new Skin();
    buttonatlas = new TextureAtlas("buttons/button.pack");
    skin.addRegions(buttonatlas);

    buttonstyle = new TextButtonStyle();
    buttonstyle.up = skin.getDrawable("button");
    buttonstyle.over = skin.getDrawable("buttonpress");
    buttonstyle.down = skin.getDrawable("buttonpress");
    buttonstyle.font = font;

    button = new TextButton("Play", buttonstyle);

    stage.addActor(button);

    button.addListener(
        new InputListener() {

          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // TODO Auto-generated method stub

            game.setScreen(new PlayScreen(game));
            MainMenu.this.dispose();
            return true;
          }
        });

    // ok

    skin2 = new Skin();
    buttonatlas2 = new TextureAtlas("buttons/button2.pack");
    skin2.addRegions(buttonatlas2);

    buttonstyle2 = new TextButtonStyle();
    buttonstyle2.up = skin2.getDrawable("button2");
    buttonstyle2.over = skin2.getDrawable("button2press");
    buttonstyle2.down = skin2.getDrawable("button2press");
    buttonstyle2.font = font;

    button2 = new TextButton("", buttonstyle2);

    button2.setPosition(Gdx.graphics.getWidth() - 250, 0);

    stage.addActor(button2);

    button2.addListener(
        new InputListener() {

          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // TODO Auto-generated method stub

            game.setScreen(new tablescreen(game));
            MainMenu.this.dispose();
            return true;
          }
        });

    batch = new SpriteBatch();

    Gdx.input.setInputProcessor(stage);
  }
Ejemplo n.º 19
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();
  }
Ejemplo n.º 20
0
  @Override
  public void show() {
    imgNinja = new Texture(Gdx.files.internal("Ninja-Shadow.png"));
    imgNinja.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("lastninja.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.genMipMaps = true;
    parameter.minFilter = Texture.TextureFilter.Linear.MipMapLinearNearest;
    parameter.magFilter = Texture.TextureFilter.Linear;
    parameter.size = 26;
    final BitmapFont font = generator.generateFont(parameter);

    startLabel = new Label("Start Game", new Label.LabelStyle(font, Color.BLACK));
    startLabel.setPosition(500, 300);
    startLabel.setTouchable(Touchable.enabled);
    startLabel.setBounds(500, 300, startLabel.getWidth(), startLabel.getHeight());
    startLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new PlayScreen(game));
            dispose();
          }
        });

    instructionLabel = new Label("Instructions", new Label.LabelStyle(font, Color.BLACK));
    instructionLabel.setPosition(500, 250);
    instructionLabel.setTouchable(Touchable.enabled);
    instructionLabel.setBounds(500, 250, instructionLabel.getWidth(), instructionLabel.getHeight());
    instructionLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new InstructionScreen(game));
            dispose();
          }
        });

    aboutLabel = new Label("About", new Label.LabelStyle(font, Color.BLACK));
    aboutLabel.setPosition(500, 200);
    aboutLabel.setTouchable(Touchable.enabled);
    aboutLabel.setBounds(500, 200, aboutLabel.getWidth(), aboutLabel.getHeight());
    aboutLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new AboutScreen(game));
            dispose();
          }
        });
    quitLabel = new Label("Quit", new Label.LabelStyle(font, Color.BLACK));
    quitLabel.setPosition(500, 150);
    quitLabel.setTouchable(Touchable.enabled);
    quitLabel.setBounds(500, 150, quitLabel.getWidth(), quitLabel.getHeight());
    quitLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });
    stage.addActor(startLabel);
    stage.addActor(instructionLabel);
    stage.addActor(aboutLabel);
    stage.addActor(quitLabel);
  }
Ejemplo n.º 21
0
  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);
  }
Ejemplo n.º 22
0
 @Override
 public void setPosition(float x, float y) {
   label.setPosition(x, y);
 }
Ejemplo n.º 23
0
  public WinnerScreen(ArrayList<Integer> playerPositions, Game game, Client client, Server server) {
    super(game, client, server);

    // Set input and viewpoint
    stage = new Stage(new StretchViewport(Constants.SCREENWIDTH, Constants.SCREENHEIGHT));
    Gdx.input.setInputProcessor(stage);

    // Unhides the cursor
    Gdx.input.setCursorCatched(false);

    this.playerPositions = playerPositions;

    // Set background
    rootTable.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.hostBackground)));
    rootTable.setFillParent(true);
    stage.addActor(rootTable);

    // Initialise Font
    FreeTypeFontGenerator.FreeTypeFontParameter fontOptions =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    fontOptions.size = 11;
    BitmapFont font = TextureManager.menuFont.generateFont(fontOptions);

    /** ------------------------LABEL STYLE------------------------* */
    Label.LabelStyle labelStyle = new Label.LabelStyle();
    fontOptions.size = 60;
    labelStyle.font = TextureManager.menuFont.generateFont(fontOptions);
    labelStyle.fontColor = Color.GOLD;

    /** ------------------------PLAYER DISPLAY WIDGET------------------------* */
    // Table options
    Table table = new Table();
    table.setFillParent(true);

    // P1 spawn field
    p1Field = new Container();
    p1Field.background(new TextureRegionDrawable(TextureManager.p1WalkingDownAnim.getKeyFrame(0)));
    table.add(p1Field).width(64).height(64);

    // P2 spawn field
    p2Field = new Container();
    p2Field.setVisible(false);
    p2Field.background(new TextureRegionDrawable(TextureManager.p2WalkingDownAnim.getKeyFrame(0)));
    table.add(p2Field).width(64).height(64).padLeft(96);

    // P3 spawn field
    p3Field = new Container();
    p3Field.setVisible(false);
    p3Field.background(new TextureRegionDrawable(TextureManager.p3WalkingDownAnim.getKeyFrame(0)));
    table.add(p3Field).width(64).height(64).padLeft(96);

    // P4 spawn field
    p4Field = new Container();
    p4Field.setVisible(false);
    p4Field.background(new TextureRegionDrawable(TextureManager.p4WalkingDownAnim.getKeyFrame(0)));
    table.add(p4Field).width(64).height(64).padLeft(96);

    // Stage & group options
    joinedPlayerGroup.addActor(table);
    joinedPlayerGroup.setPosition(443, 150);
    stage.addActor(joinedPlayerGroup);

    /** ------------------------PLAYER HIGHLIGHT WIDGET------------------------* */
    // Table options
    Table table2 = new Table();
    table2.setFillParent(true);

    // P1 spawn field
    p1FieldHighlight = new Container();
    p1FieldHighlight.setVisible(false);
    p1FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p1FieldHighlight).width(80).height(77);

    // P2 spawn field
    p2FieldHighlight = new Container();
    p2FieldHighlight.setVisible(false);
    p2FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p2FieldHighlight).width(80).height(77).padLeft(80);

    // P3 spawn field
    p3FieldHighlight = new Container();
    p3FieldHighlight.setVisible(false);
    p3FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p3FieldHighlight).width(80).height(77).padLeft(80);

    // P4 spawn field
    p4FieldHighlight = new Container();
    p4FieldHighlight.setVisible(false);
    p4FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p4FieldHighlight).width(80).height(77).padLeft(80);

    // Stage & group options
    playerhighlightWidget.addActor(table2);
    playerhighlightWidget.setPosition(442, 152);
    stage.addActor(playerhighlightWidget);

    /** ------------------------LABELS------------------------* */

    // Titel
    titel = new Label("", labelStyle);
    titel.setAlignment(Align.center);
    titel.setPosition((Constants.SCREENWIDTH - titel.getWidth()) / 2 + 50, 385);
    stage.addActor(titel);

    // If you are the winner
    if (Constants.PLAYERID == playerPositions.get(playerPositions.size() - 1)) {
      titel.setText("YOU WON!");
      isWinner = true;
    } else {
      isWinner = false;
      titel.setText("YOU LOOSE!");
      titel.setColor(Color.RED);
    }

    if (-1 == playerPositions.get(playerPositions.size() - 1)) {
      titel.setText("DRAW!");
      titel.setColor(Color.DARK_GRAY);
      isWinner = false;
    }

    Table positionTable = new Table();
    positionTable.setFillParent(true);

    p1Position = new Label("", labelStyle);
    p1Position.setAlignment(Align.center);

    p2Position = new Label("", labelStyle);
    p2Position.setAlignment(Align.center);

    p3Position = new Label("", labelStyle);
    p3Position.setAlignment(Align.center);

    p4Position = new Label("", labelStyle);
    p4Position.setAlignment(Align.center);

    positionTable.add(p1Position).width(64).height(64);
    positionTable.add(p2Position).width(64).height(64).padLeft(96);
    positionTable.add(p3Position).width(64).height(64).padLeft(96);
    positionTable.add(p4Position).width(64).height(64).padLeft(96);

    positionPlayerWidget.addActor(positionTable);
    positionPlayerWidget.setPosition(443, 230);
    stage.addActor(positionPlayerWidget);

    /** ------------------------MUSIC------------------------* */
    if (isWinner == false) {
      AudioManager.setCurrentMusic(AudioManager.getLooserMusic());
      AudioManager.getCurrentMusic().setLooping(true);
      AudioManager.getCurrentMusic().play();
      AudioManager.getCurrentMusic().setVolume(AudioManager.getMusicVolume() * 4);
    } else {
      AudioManager.setCurrentMusic(AudioManager.getWinnerMusic());
      AudioManager.getCurrentMusic().setLooping(true);
      AudioManager.getCurrentMusic().play();
      AudioManager.getCurrentMusic().setVolume(AudioManager.getMusicVolume() * 6);
    }

    /** ------------------------BUTTONS------------------------* */
    TextButton.TextButtonStyle textButtonStyleBack = new TextButton.TextButtonStyle();
    textButtonStyleBack.font = font;
    textButtonStyleBack.up = backSkin.getDrawable("button_up");
    textButtonStyleBack.down = backSkin.getDrawable("button_down");
    textButtonStyleBack.over = backSkin.getDrawable("button_checked");

    // Back button
    backButton = new TextButton("", textButtonStyleBack);
    backButton.setPosition(0, Constants.SCREENHEIGHT - backButton.getHeight() + 7);
    stage.addActor(backButton);

    renderPlayers();

    // Add click listener --> Back button
    backButton.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            // Add click musik
            AudioManager.playClickSound();

            // Wait till sound is done
            try {
              Thread.sleep(100);

            } catch (InterruptedException ex) {

            }

            if (isWinner) {
              AudioManager.getCurrentMusic().stop();
            } else {
              AudioManager.getCurrentMusic().stop();
            }

            server.stopServer();
            game.setScreen(new MenuScreen(game, client, server));
          }
        });
  }
Ejemplo n.º 24
0
  @Override
  public void create() {

    //		Gdx.gl.glClearColor(
    //			background.rgb.getRed() / 255f,
    //			background.rgb.getGreen() / 255f,
    //			background.rgb.getBlue() / 255f,
    //			background.rgb.getAlpha() / 255f);
    //		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    //		Gdx.graphics.setContinuousRendering(false);
    //		Gdx.graphics.requestRendering();

    cam = new OrthographicCamera();
    batch = new SpriteBatch();

    stage = new Stage();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    input = new TextField("", skin);

    // can't use Table here since it will conflict with the Swing Table toolkit
    // this is why static is shit -.-
    labelInput = new Label("Sample Text:", skin);
    labelScale = new Label("Scale:", skin);
    scaleAmt = new Label("1.0", skin);

    labelInput.setHeight(input.getHeight());
    labelInput.setPosition(10, Gdx.graphics.getHeight() - labelInput.getHeight() - 5);
    input.setPosition(
        labelInput.getX() + labelInput.getWidth() + 10,
        Gdx.graphics.getHeight() - input.getHeight() - 5);

    scaleSlider = new Slider(0, 3, 0.05f, false, skin);
    scaleSlider.setSnapToValues(new float[] {0.0f, 0.5f, 1.0f}, 0.05f);

    scaleSlider.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent arg0, Actor arg1) {
            scaleAmt.setText(String.format("%.2f", scaleSlider.getValue()));
          }
        });
    scaleSlider.setValue(1.0f);
    scaleAmt.setText(String.format("%.2f", scaleSlider.getValue()));

    linearFiltering = new ToggleBox("Linear Filtering", skin);
    linearFiltering.addListener(
        new ClickListener() {
          public void clicked(InputEvent ev, float x, float y) {
            updateFiltering();
          }
        });

    scaleAmt.setHeight(scaleSlider.getHeight());
    labelScale.setHeight(scaleSlider.getHeight());

    labelScale.setPosition(
        input.getX() - 10 - labelScale.getWidth(), labelInput.getY() - labelInput.getHeight() - 5);
    scaleSlider.setPosition(input.getX(), input.getY() - input.getHeight() - 5);
    scaleAmt.setPosition(scaleSlider.getX() + scaleSlider.getWidth() + 5, scaleSlider.getY());

    linearFiltering.setPosition(input.getX(), scaleSlider.getY() - scaleSlider.getHeight() - 10);

    Gdx.input.setInputProcessor(stage);
    stage.addActor(labelInput);
    stage.addActor(input);
    stage.addActor(labelScale);
    stage.addActor(scaleSlider);
    stage.addActor(scaleAmt);
    stage.addActor(linearFiltering);

    myButton = new TextButton("Blah", skin);
  }
Ejemplo n.º 25
0
  public Stage_Game(Viewport viewport) {
    super(viewport);

    unprojected = new Vector3(0, 0, 0);

    Gdx.input.setCatchBackKey(true);

    pauseButton = new ImageButton(skin, "pause");
    pauseButton.getStyle().imageChecked.setMinWidth(150);
    pauseButton.getStyle().imageChecked.setMinHeight(150);
    pauseButton.setBounds(880, 1720, 150, 150);
    pauseButton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            pause = !pause;
            pauseButton.setChecked(pause);
            exitButton.setVisible(pause);
            MainClass.clickSound.play(MainClass.sound);
          }
        });
    exitButton = new ImageButton(skin, "exit");
    exitButton.setBounds(880, 1550, 150, 150);
    exitButton.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            MainClass.setCurrentStage(new Stage_Menu(getViewport()));
            MainClass.clickSound.play(MainClass.sound);
            super.clicked(event, x, y);
          }
        });
    exitButton.setVisible(false);

    gameOver = false;
    pause = false;

    bodyY = new Array<Float>();
    camera = new OrthographicCamera(5.628f, 10.0f);
    camera.position.set(2.814f, 4, 0);
    camY = 4;
    camera.update();

    muffinSource =
        new Actor() {
          @Override
          public void draw(Batch batch, float parentAlpha) {
            super.draw(batch, parentAlpha);
            muffinSourceSprite.setBounds(425, 1680, 230, 186);
            muffinSourceSprite.setScale(getScaleX());
            muffinSourceSprite.draw(batch);
          }
        };
    muffinSource.setBounds(425, 1680, 230, 186);
    muffinSource.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (muffinSource.getScaleX() >= 1 && !pause && !gameOver) {
              newMuffinSound.play(MainClass.sound);
              unprojected = camera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0));
              muffinBodyDef.position.set(new Vector2(unprojected.x - 0.5f, unprojected.y - 0.5f));
              tmpbd = world.createBody(muffinBodyDef);
              loader.attachFixture(tmpbd, "MuffinModel", muffinFixtureDef, 1.1f, 1.1f, 1.1f);
              tmpbd.setFixedRotation(true);
              drag = true;

              muffinSource.setScale(0.1f);

              ScaleToAction getNormal = new ScaleToAction();
              getNormal.setScale(1);
              getNormal.setDuration(0.4f);

              mpHandler.addParticle(unprojected.x, unprojected.y, tmpbd);

              muffinSource.addAction(getNormal);
            }

            return super.touchDown(event, x, y, pointer, button);
          }
        });

    score = 0;
    scoreLabel = new Label("Score: 0", skin, "score");
    scoreLabel.setPosition(15, 1920 - scoreLabel.getHeight());

    /** TEXTURES * */
    fireEffect = new ParticleEffect();
    fireEffect = AssetLoader.manager.get(AssetLoader.fireParticlePath);

    mpHandler = new MuffinParticleHandler(fireEffect);

    textures = AssetLoader.manager.get(AssetLoader.uiAtlasPath, TextureAtlas.class);

    normalmuffinface = textures.createSprite("muffin_face_normal");
    scaredmuffinface = textures.createSprite("muffin_face_scared");
    awakemuffinface = textures.createSprite("muffin_face_awake");
    traySprite = textures.createSprite("tray");
    traySprite.setPosition(0.3f, -1.8f);
    traySprite.setSize(4.4f, 2.19f);

    backgrounds = new Sprite[5];
    for (i = 0; i < 5; i++) {
      backgrounds[i] =
          new Sprite(
              AssetLoader.manager.get("menu/back" + String.valueOf(i + 1) + ".png", Texture.class));
      backgrounds[i].setBounds(
          camera.position.x - (camera.viewportWidth / 2),
          camera.position.y - (camera.viewportHeight / 2) + (i * 1920 / 192),
          (float) 1080 / 192,
          (float) 1920 / 192);
    }

    batch = new SpriteBatch();
    batch.setProjectionMatrix(camera.combined);
    muffinSprite = textures.createSprite("muffin");
    muffinSourceSprite = textures.createSprite("muffin");
    muffinSourceSprite.setBounds(450, 1714, 180, 146);
    muffinSourceSprite.setOrigin(90, 73);

    /** PHYSICS * */
    bodies = new Array<Body>();

    // WORLD

    world = new World(new Vector2(0, -10f), true);
    renderer = new Box2DDebugRenderer();

    // PLATE

    BodyDef plateDef = new BodyDef();
    plateDef.type = BodyDef.BodyType.StaticBody;
    plateDef.position.set(2.814f, 0.25f);

    plate = world.createBody(plateDef);

    FixtureDef plateFixtureDef = new FixtureDef();
    PolygonShape plateShape = new PolygonShape();
    plateShape.setAsBox(1.8f, 0.1f);
    plateFixtureDef.shape = plateShape;
    plateFixtureDef.friction = 0.9f;
    // plateFixtureDef.density = 1;

    plate.createFixture(plateFixtureDef);
    plateShape.dispose();

    // MUFFIN

    loader = new BodyEditorLoader(Gdx.files.internal("physics/muffin.json"));

    muffinBodyDef = new BodyDef();
    muffinBodyDef.type = BodyDef.BodyType.DynamicBody;
    muffinBodyDef.bullet = true;

    muffinFixtureDef = new FixtureDef();
    muffinFixtureDef.density = 0.7f;
    muffinFixtureDef.friction = 0.5f;
    muffinFixtureDef.restitution = 0.1f;

    muffinOrigin = loader.getOrigin("MuffinModel", 1.1f).cpy();

    gameOverDialog = new Dialog_GameOver("", skin, "default");

    /** SOUNDS * */
    newHighScoreSound = AssetLoader.manager.get(AssetLoader.clappingPath, Sound.class);
    gameOverSound = AssetLoader.manager.get(AssetLoader.gameOverPath, Sound.class);
    newMuffinSound = AssetLoader.manager.get(AssetLoader.newMuffinPath, Sound.class);

    addActor(pauseButton);
    addActor(exitButton);
    addActor(muffinSource);
    addActor(scoreLabel);
  }
Ejemplo n.º 26
0
 public void setLabel(Label Lab) {
   Lab.setPosition(getX(), getY());
   Lab.setSize(getWidth(), getHeight());
   Lab.setAlignment(Align.center | Align.top);
   this.Lab = Lab;
 }
Ejemplo n.º 27
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);
  }
Ejemplo n.º 28
0
  @Override
  public void show() {
    // Creates an stage that contains all the GUI elements
    stage = new Stage();
    stage.clear();
    Gdx.input.setInputProcessor(stage);

    // Title label
    font100orange = new BitmapFont(Gdx.files.internal("fonts/prehistorik100orange.fnt"));
    titleLabel = new Label(this.title, new LabelStyle(font100orange, Color.WHITE));
    titleLabel.setPosition(
        Gdx.graphics.getWidth() / 2.0f - titleLabel.getWidth() / 2,
        7.1f * Gdx.graphics.getHeight() / 9.0f);

    // Textbox label
    white30boldFont = new BitmapFont(Gdx.files.internal("fonts/white30bold.fnt"));
    label1 = new Label("IP adress of game creator:", new LabelStyle(white30boldFont, Color.WHITE));
    label1.setPosition(
        Gdx.graphics.getWidth() / 2.0f - label1.getWidth() / 2,
        6 * Gdx.graphics.getHeight() / 9.0f);

    // Username
    Label usernameLabel = ScreenUtils.createLabel("Username:"******"", 0, 0);
    usernameInput.setPosition(
        Gdx.graphics.getWidth() / 2f - usernameInput.getWidth() / 2f,
        3 * Gdx.graphics.getHeight() / 9.0f);

    // Atlas of the GUI
    atlas = new TextureAtlas("gui/gui.pack");
    skin = new Skin(atlas);

    // Buttons
    font60 = new BitmapFont(Gdx.files.internal("fonts/prehistorik60black.fnt"), false);
    TextButtonStyle buttonStyle = new TextButtonStyle();
    buttonStyle.up = skin.getDrawable("button1");
    buttonStyle.over = skin.getDrawable("button1-over");
    buttonStyle.down = skin.getDrawable("button1-down");
    buttonStyle.font = font60;

    joinButton = new TextButton("Join Game", buttonStyle);
    joinButton.setHeight(100f);
    joinButton.setWidth(500f);
    joinButton.setPosition(
        Gdx.graphics.getWidth() / 2.0f - joinButton.getWidth() / 2,
        1.5f * Gdx.graphics.getHeight() / 9.0f);

    menuButton = new TextButton("Main Menu", buttonStyle);
    menuButton.setHeight(100f);
    menuButton.setWidth(500f);
    menuButton.setPosition(
        Gdx.graphics.getWidth() / 2.0f - joinButton.getWidth() / 2,
        0f * Gdx.graphics.getHeight() / 9.0f);

    // TextField
    white36nonoFont = new BitmapFont(Gdx.files.internal("fonts/white36mono.fnt"));
    TextFieldStyle tfs = new TextFieldStyle();
    tfs.font = white36nonoFont;
    tfs.cursor = skin.getDrawable("cursor");
    tfs.background = skin.getDrawable("textField");
    tfs.fontColor = Color.WHITE;
    inputAddress = new TextField("localhost", tfs);
    inputAddress.setHeight(50);
    inputAddress.setWidth(300);
    inputAddress.setPosition(
        Gdx.graphics.getWidth() / 2.0f - inputAddress.getWidth() / 2,
        5 * Gdx.graphics.getHeight() / 9.0f);

    // add actors
    stage.addActor(joinButton);
    stage.addActor(menuButton);
    stage.addActor(inputAddress);
    stage.addActor(titleLabel);
    stage.addActor(usernameLabel);
    stage.addActor(usernameInput);
    stage.addActor(titleLabel);
    stage.addActor(label1);

    joinButton.addListener(
        new ChangeListener() {

          @Override
          public void changed(ChangeEvent event, Actor actor) {
            System.out.println(inputAddress.getText());

            GameScreen.createInstance(game, false, inputAddress.getText(), usernameInput.getText());
            game.setScreen(GameScreen.getInstance());
            //						game.initInputListeners();

          }
        });

    menuButton.addListener(
        new ChangeListener() {

          @Override
          public void changed(ChangeEvent event, Actor actor) {
            game.setScreen(new MenuScreen(game));
          }
        });
  }