Ejemplo n.º 1
0
  private void loadScreen() {

    // Grafo de escena que contendrá todo el menú
    stage = new Stage();

    // Crea una tabla, donde añadiremos los elementos de menú
    Table table = new Table();
    table.setPosition(Constants.SCREEN_WIDTH / 2.5f, Constants.SCREEN_HEIGHT / 1.5f);
    // La tabla ocupa toda la pantalla
    table.setFillParent(true);
    table.setHeight(500);
    stage.addActor(table);

    // Etiqueta de texto
    Label label = new Label("Bienvenido a JFighter2DX", game.getSkin());
    table.addActor(label);

    // Botón
    TextButton buttonPlay = new TextButton("Partida Rapida", game.getSkin());
    buttonPlay.setPosition(label.getOriginX(), label.getOriginY() - 120);
    buttonPlay.setWidth(200);
    buttonPlay.setHeight(40);
    buttonPlay.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) {

            dispose();
            game.setScreen(new GameScreen(game, GameType.QUICK));
          }
        });
    table.addActor(buttonPlay);

    // Botón
    TextButton buttonHistory = new TextButton("Modo Historia", game.getSkin());
    buttonHistory.setPosition(label.getOriginX(), label.getOriginY() - 170);
    buttonHistory.setWidth(200);
    buttonHistory.setHeight(40);
    buttonHistory.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) {

            dispose();
            game.setScreen(new GameScreen(game, GameType.HISTORY));
          }
        });
    table.addActor(buttonHistory);

    // Botón
    TextButton buttonConfig = new TextButton("Configurar", game.getSkin());
    buttonConfig.setPosition(label.getOriginX(), label.getOriginY() - 220);
    buttonConfig.setWidth(200);
    buttonConfig.setHeight(40);
    buttonConfig.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) {

            dispose();
            game.setScreen(new ConfigurationScreen(game));
          }
        });
    table.addActor(buttonConfig);

    // Botón
    TextButton buttonQuit = new TextButton("Salir", game.getSkin());
    buttonQuit.setPosition(label.getOriginX(), label.getOriginY() - 270);
    buttonQuit.setWidth(200);
    buttonQuit.setHeight(40);
    buttonQuit.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) {

            game.dispose();
            System.exit(0);
          }
        });
    table.addActor(buttonQuit);

    Gdx.input.setInputProcessor(stage);
  }