コード例 #1
0
 @Override
 public void dispose() {
   startLabel.setTouchable(Touchable.disabled);
   instructionLabel.setTouchable(Touchable.disabled);
   aboutLabel.setTouchable(Touchable.disabled);
   quitLabel.setTouchable(Touchable.disabled);
 }
コード例 #2
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);
    }
  }
コード例 #3
0
  @Override
  public void show() {
    imgNinja = new Texture(Gdx.files.internal("Ninja-Shadow.png"));
    imgNinja.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("lastninja.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.genMipMaps = true;
    parameter.minFilter = Texture.TextureFilter.Linear.MipMapLinearNearest;
    parameter.magFilter = Texture.TextureFilter.Linear;
    parameter.size = 26;
    final BitmapFont font = generator.generateFont(parameter);

    startLabel = new Label("Start Game", new Label.LabelStyle(font, Color.BLACK));
    startLabel.setPosition(500, 300);
    startLabel.setTouchable(Touchable.enabled);
    startLabel.setBounds(500, 300, startLabel.getWidth(), startLabel.getHeight());
    startLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new PlayScreen(game));
            dispose();
          }
        });

    instructionLabel = new Label("Instructions", new Label.LabelStyle(font, Color.BLACK));
    instructionLabel.setPosition(500, 250);
    instructionLabel.setTouchable(Touchable.enabled);
    instructionLabel.setBounds(500, 250, instructionLabel.getWidth(), instructionLabel.getHeight());
    instructionLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new InstructionScreen(game));
            dispose();
          }
        });

    aboutLabel = new Label("About", new Label.LabelStyle(font, Color.BLACK));
    aboutLabel.setPosition(500, 200);
    aboutLabel.setTouchable(Touchable.enabled);
    aboutLabel.setBounds(500, 200, aboutLabel.getWidth(), aboutLabel.getHeight());
    aboutLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new AboutScreen(game));
            dispose();
          }
        });
    quitLabel = new Label("Quit", new Label.LabelStyle(font, Color.BLACK));
    quitLabel.setPosition(500, 150);
    quitLabel.setTouchable(Touchable.enabled);
    quitLabel.setBounds(500, 150, quitLabel.getWidth(), quitLabel.getHeight());
    quitLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });
    stage.addActor(startLabel);
    stage.addActor(instructionLabel);
    stage.addActor(aboutLabel);
    stage.addActor(quitLabel);
  }