public void update(float dt, OrthographicCamera cam) {
    stage.act(dt);
    if (Core.persistentAssets.update() && !assetsLoaded) {

      GameSave.save();

      assetsLoaded = true;

      layout = new Table(Core.persistentAssets.get("skins/uiskin.json", Skin.class));
      layout.setFillParent(true);
      layout.center().bottom();

      pressBtn =
          new Label(
              "Press any key to continue",
              Core.persistentAssets.get("skins/uiskin.json", Skin.class));

      layout.add(pressBtn).padBottom(40);

      layout.debug();

      stage.addActor(layout);

      stage.addListener(
          new InputListener() {
            public boolean keyUp(InputEvent event, int keycode) {
              gsm.setState(GameStateManager.MENU);
              return false;
            }

            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) {
              gsm.setState(GameStateManager.MENU);
            }
          });
    }

    if (Core.persistentAssets.isLoaded("images/main-menu/background.jpg")) {
      if (!bgLoaded) {
        bgLoaded = true;
        bg =
            new Sprite(Core.persistentAssets.get("images/main-menu/background.jpg", Texture.class));
        float[] size =
            ImageUtils.minimalStretch(bg.getWidth(), bg.getHeight(), Core.WIDTH, Core.HEIGHT);

        bg.setSize(size[0], size[1]);
        bg.setPosition(size[2], size[3]);
      }
      bgOpacity += bgOpacityModifier * dt;
      bgOpacity = bgOpacity > 1 ? 1 : bgOpacity;
    }
  }
 /** Set benchmark table position */
 public void setUpPosition(BenchmarkPosition benchmarkPosition) {
   switch (benchmarkPosition) {
     case CENTER:
       table.center();
       break;
     case TOP_LEFT:
       table.top().left();
       break;
     case TOP_RIGHT:
       table.top().right();
       break;
     case BOTTOM_LEFT:
       table.bottom().left();
       break;
     case BOTTOM_RIGHT:
       table.bottom().right();
       break;
     default:
       table.top().left();
       break;
   }
 }
Exemple #3
0
  public GameOverlay() {
    batch = new SpriteBatch();
    stage = new Stage();
    inMux = new InputMultiplexer();
    inMux.addProcessor(stage);
    overlayStage = new Stage();

    topMenu = new Table();
    topMenu.setFillParent(true);
    topMenu.top();
    topMenu.left();
    stage.addActor(topMenu);

    bottomMenu = new Table();
    bottomMenu.setFillParent(true);
    bottomMenu.bottom();
    stage.addActor(bottomMenu);

    overlayMenu = new Table();
    overlayMenu.setFillParent(true);
    overlayMenu.center();
    overlayStage.addActor(overlayMenu);
  }
  public void initTable() {
    table = new Table();
    table.setWidth(getWidth());
    table.setFillParent(true);
    table.center();
    table.debug();

    titleLabel = new TransparentBackgroundLabel(this.game, "", skin, "default_label");
    // Make it bigger
    titleLabel.setFontScale(1.0f);
    titleLabel.setWrap(true);
    titleLabel.setAlignment(Align.center);

    definitionLabel = new TransparentBackgroundLabel(this.game, "", skin, "default_label");
    definitionLabel.setFontScale(0.6f);
    definitionLabel.setWrap(true);
    definitionLabel.setAlignment(Align.center);

    table
        .add(titleLabel)
        .center()
        .expand()
        .width(getWidth() * 0.9f)
        .padTop(70f)
        .height(getHeight() * 0.10f);
    table.row();
    table
        .add(definitionLabel)
        .center()
        .top()
        .expand()
        .width(getWidth() * 0.9f)
        .maxHeight(getHeight() * 0.7f)
        .spaceBottom(150f);
    this.addActor(table);
  }