コード例 #1
0
  /** Sets the loading to finished and displays the finished loading message. */
  public void loadingFinished() {
    if (!progressLabel.getText().equals(ON_FINISHED_LABEL_TEXT)) {
      progressLabel.setText(ON_FINISHED_LABEL_TEXT);
      centerProgressLabel();

      loadBar.setScaleX(1);
      loadBar.invalidate();
    }
  }
コード例 #2
0
  /**
   * Sets the displayed loadProgress.
   *
   * @param loadProgress the current load progress, in percentage from 0 to 1.
   */
  public void setLoadProgress(float loadProgress) {
    percent = Interpolation.linear.apply(percent, loadProgress, 0.1f);

    progressLabel.setText(String.format(PROGRESS_LABEL_TEXT, (int) Math.floor(percent * 100)));
    centerProgressLabel();

    // The width scaling is applied from the middle, resulting in non-transparent parts of the
    // loading bar overlapping the loading bar background. The below is an attempt to counter
    // that.
    float xPercent = 1 - Math.min((float) (percent / 0.5), 1);
    loadBar.setX(loadBarBg.getX() + 4 * xPercent);

    loadBar.setScaleX(percent);
    loadBar.invalidate();
  }
コード例 #3
0
  public void initComponents() {
    stage.clear();

    background =
        new Image(
            new TextureRegion(
                new Texture(
                    Gdx.files.internal(
                        FileMap.resourcesToDirectory.get("game_ui_images")
                            + "logo_shadow_struggles.png")),
                512,
                512));
    background.setScaleX(960f / 512f);
    background.setScaleY(640f / 512f);
    background.setY(background.getImageY() + 100);

    stage.addActor(background);
  }
コード例 #4
0
ファイル: CustomTabBar.java プロジェクト: Gskran/overlap2d
  public void initView() {
    clear();
    float currPos = 0;
    for (int i = 0; i < tabs.size(); i++) {
      boolean isSelected = false;
      if (i == selectedTabIndex) isSelected = true;
      String imgName = "tab";
      if (isSelected) {
        imgName = "tabS";
      }
      Image img = new Image(s.textureManager.getEditorAsset(imgName));
      img.setX(currPos);
      img.setY(0);

      Label lbl = new Label(tabs.get(i), s.textureManager.editorSkin);
      lbl.setX(currPos + 6);
      lbl.setY(2);
      lbl.setTouchable(Touchable.disabled);

      img.setScaleX(lbl.getWidth() + 12);
      currPos += lbl.getWidth() + 12;

      addActor(img);
      addActor(lbl);

      Image sep = new Image(s.textureManager.getEditorAsset("tabSep"));
      sep.setX(img.getX() + img.getScaleX());
      addActor(sep);
      currPos += 1;

      if (isSelected) {
        lbl.setColor(1, 1, 1, 1);
      } else {
        lbl.setColor(1, 1, 1, 0.65f);
      }

      final int currIndex = i;

      img.addListener(
          new ClickListener() {
            public void clicked(InputEvent event, float x, float y) {
              selectedTabIndex = currIndex;
              initView();
              if (tabEventListener != null) {
                tabEventListener.tabOpened(currIndex);
              }
            }
          });

      setHeight(img.getHeight());
    }

    float currWidth = currPos;
    if (getWidth() > currWidth) {
      float diff = getWidth() - currWidth;
      Image rest = new Image(s.textureManager.getEditorAsset("tab"));
      rest.setX(currPos);
      rest.setScaleX(diff);
      addActor(rest);
    }
  }