示例#1
0
  @Override
  public void resize(int width, int height) {
    if (stage == null) {
      stage = new Stage(width, height, true);
    }
    stage.clear();

    Gdx.input.setInputProcessor(stage);

    TextButtonStyle butStyle = new TextButtonStyle();
    butStyle.up = butSkin.getDrawable("butdown");
    butStyle.down = butSkin.getDrawable("butup");
    butStyle.font = font1;

    LabelStyle labelStyle = new LabelStyle();
    labelStyle.font = font1;

    mainButton = new TextButton("Start Game!", butStyle);
    closeButton = new TextButton("Do nothing", butStyle);

    mainButton.setWidth(400);
    mainButton.setHeight(100);
    mainButton.setX(Gdx.graphics.getWidth() / 2 - mainButton.getWidth() / 2);
    mainButton.setY(Gdx.graphics.getHeight() / 2 - 2 * (mainButton.getHeight() / 1.2f));

    closeButton.setWidth(400);
    closeButton.setHeight(100);
    closeButton.setX(Gdx.graphics.getWidth() / 2 - closeButton.getWidth() / 2);
    closeButton.setY(
        Gdx.graphics.getHeight() / 2
            - 2 * (closeButton.getHeight() / 1.2f)
            - (closeButton.getHeight() + 5));

    mainButton.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("down");
            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            golf.setCall(false); // disable splash screen after first use
            golf.setScreen(golf.hole, 1);
          }
        });

    stage.addActor(mainButton);
    stage.addActor(closeButton);
  }
  public UIHelper() {
    stage = new Stage();
    uiSkin = new Skin(Gdx.files.internal("data/uiskin.json"));

    loadTouchpad();

    final TextButton button = new TextButton("place team", uiSkin, "default");

    float width = Gdx.graphics.getWidth();
    float height = Gdx.graphics.getHeight();

    button.setWidth(100);
    button.setHeight(50);
    button.setPosition(width - 120, 20);

    button.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            placeTeam = !placeTeam;
            if (placeTeam) button.setText("ACTIVE");
            else button.setText("place team");
          }
        });

    final TextButton button2 = new TextButton("place enemy", uiSkin, "default");

    button2.setWidth(100);
    button2.setHeight(50);
    button2.setPosition(width - 240, 20);

    button2.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            placeEnemy = !placeEnemy;
            if (placeEnemy) button2.setText("ACTIVE");
            else button2.setText("place enemy");
          }
        });

    stage.addActor(button);
    stage.addActor(button2);
  }
示例#3
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);
  }
示例#4
0
    public TextButton get9PatchButton(String buttonText) {
      // Drawable tmpDrawable = skinButton.newDrawable(skinButton.getDrawable("default"));
      TextButton btn = new TextButton(buttonText, skinButton);
      // TextButton btn = new TextButton(buttonText, tmpDrawable);
      btn.setHeight(btn.getHeight() * 0.75f);

      btn.setX(Gdx.graphics.getWidth() / 2 - btn.getWidth() / 2);
      btn.setY(Gdx.graphics.getHeight() / 2);

      return btn;
    }
示例#5
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);
  }
示例#6
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));
          }
        });
  }