コード例 #1
0
  public void render(float delta) {
    Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1);
    Gdx.gl.glClear(GL_COLOR_BUFFER_BIT);

    buttonRenderer.begin();
    {
      for (Button button : buttons) {
        button.render(buttonRenderer);
      }
    }
    buttonRenderer.end();
  }
コード例 #2
0
  public void resize(int width, int height) {
    MiningAdventure.mining.setCurrentScreen(MiningAdventure.START_SCREEN);

    this.width = width;
    this.height = height;

    buttonHeight = height / 9F;

    float spacer = 10F;
    float buttonWidth = (width * ((3F / 4F) / 2F));

    text = MiningAdventure.label;

    levelExp =
        new Button(
            text,
            "External Level",
            (width / 2F) - (buttonWidth),
            height - (buttonHeight + spacer),
            (buttonWidth * 2F),
            buttonHeight);

    level1 =
        new Button(
            text,
            "Level 1",
            (width / 2F) - ((buttonWidth)),
            levelExp.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);
    level2 =
        new Button(
            text,
            "Level 2",
            (width / 2F) - ((buttonWidth)),
            level1.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);
    level3 =
        new Button(
            text,
            "Level 3",
            (width / 2F) - ((buttonWidth)),
            level2.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);
    level4 =
        new Button(
            text,
            "Level 4",
            level1.x + level1.width + spacer,
            levelExp.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);
    level5 =
        new Button(
            text,
            "Level 5",
            level2.x + level2.width + spacer,
            level4.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);
    level6 =
        new Button(
            text,
            "Level 6",
            level3.x + level3.width + spacer,
            level5.y - (buttonHeight + spacer),
            buttonWidth - (spacer / 2F),
            buttonHeight);

    options =
        new Button(
            text,
            "Options",
            (width / 2F) - (buttonWidth),
            (spacer * 2) + buttonHeight,
            (buttonWidth * 2F),
            buttonHeight);
    exit =
        new Button(
            text, "Exit", (width / 2F) - (buttonWidth), spacer, (buttonWidth * 2F), buttonHeight);

    buttons.clear();

    if (Gdx.files.isExternalStorageAvailable()) {
      FileHandle file = new FileHandle(Gdx.files.getExternalStoragePath() + "levelExp.txt");
      System.out.println(file.path());
      if (file.exists()) {
        buttons.add(levelExp.setActionNumber(-1));
      }
    }

    buttons.add(level1.setActionNumber(1));
    buttons.add(level2.setActionNumber(2));
    buttons.add(level3.setActionNumber(3));

    buttons.add(level4.setActionNumber(4));
    /*buttons.add(level5.setActionNumber(5));
    buttons.add(level6.setActionNumber(6));*/

    buttons.add(options.setActionNumber(-3));
    buttons.add(exit.setActionNumber(-2));
  }