Exemple #1
0
  @Override
  public void show() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    table = new Table();
    table.setFillParent(true);
    // table.row();
    table.right();

    mainInit();
    buttonInit();

    stage.addActor(table);
  }
Exemple #2
0
  private void buttonInit() {
    Button newGameButton;
    Button.ButtonStyle buttonStyle;

    buttonStyle = new Button.ButtonStyle();
    buttonStyle.up = GameResource.getInstance().getDrawable("new_button");
    buttonStyle.down = GameResource.getInstance().getDrawable("new_button_pressed");
    newGameButton = new Button(buttonStyle);
    newGameButton.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) {
            music.stop();
            currentGame.setScreen(currentGame.gameScreen);
            // currentGame.setScreen(currentGame.loadingScreen);
          }
        });

    Button loadGameButton;
    buttonStyle = new Button.ButtonStyle();
    buttonStyle.up = GameResource.getInstance().getDrawable("load_button");
    buttonStyle.down = GameResource.getInstance().getDrawable("load_button_pressed");
    loadGameButton = new Button(buttonStyle);
    loadGameButton.addListener(
        new InputListener() {
          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            // load logic
          }
        });

    table.add(newGameButton).padRight(80).padBottom(20).width(150).height(70);
    table.row();
    table.add(loadGameButton).padRight(80).width(150).height(70);
  }