コード例 #1
0
ファイル: Menu.java プロジェクト: vieux/hnefatafl
  private void onExit(
      final Screen screen, TextButton buttonPlay, TextButton buttonCredits, TextButton buttonExit) {

    Tween.set(buttonPlay, ActorAccessor.ALPHA)
        .target(buttonPlay.getColor().a)
        .start(getTweenManager());
    Tween.to(buttonPlay, ActorAccessor.ALPHA, 0.5f).target(0).delay(0.2f).start(getTweenManager());
    Tween.set(buttonCredits, ActorAccessor.ALPHA)
        .target(buttonCredits.getColor().a)
        .start(getTweenManager());
    Tween.to(buttonCredits, ActorAccessor.ALPHA, 0.5f)
        .target(0)
        .delay(0.1f)
        .start(getTweenManager());
    Tween.set(buttonExit, ActorAccessor.ALPHA)
        .target(buttonExit.getColor().a)
        .start(getTweenManager());
    Tween.to(buttonExit, ActorAccessor.ALPHA, 0.5f)
        .target(0)
        .setCallback(
            new TweenCallback() {

              @Override
              public void onEvent(int type, BaseTween<?> source) {
                getGame().setScreen(screen);
              }
            })
        .start(getTweenManager());
  }
コード例 #2
0
ファイル: MainMenu.java プロジェクト: ruthlessgames/zwali-git
  private void popButtons() {
    // TODO Auto-generated method stub
    final TextButton btnOpt = new TextButton("Options", StylesManager.btnGray);
    final TextButton btnCloud = new TextButton("Cloud", StylesManager.btnGray);
    final TextButton btnPlay = new TextButton("Play", StylesManager.btnBlue);
    final TextButton btnSur = new TextButton("Survival", StylesManager.btnGreen);
    final TextButton btnCamp = new TextButton("Campaign", StylesManager.btnGreen);
    final Image imgCloud = new Image(Textures.cloud);
    imgCloud.setPosition(570, -140);

    // game modes btns

    btnSur.setBounds(250, 180, 150, 35);
    btnSur.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) {
            if (x < btnSur.getWidth() && x > 0 && y < btnSur.getHeight() && y > 0) {
              maingame.setScreen(
                  maingame.questsScreen.generateScreen(
                      maingame.constDump.Survival(maingame.constDump.Home())));
              btnSur.addAction(Actions.fadeOut(1));
              btnCamp.addAction(Actions.fadeOut(1));
              btnPlay.setVisible(true);
              btnPlay.addAction(Actions.fadeIn(1));
            }
          }
        });
    btnSur.getColor().a = 0;
    table.addActor(btnSur);

    btnCamp.setBounds(410, 180, 150, 35);
    btnCamp.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) {
            if (x < btnCamp.getWidth() && x > 0 && y < btnCamp.getHeight() && y > 0) {
              maingame.setScreen(maingame.questsScreen);

              btnSur.addAction(Actions.fadeOut(1));
              btnCamp.addAction(Actions.fadeOut(1));
              btnPlay.setVisible(true);
              btnPlay.addAction(Actions.fadeIn(1));
            }
          }
        });
    btnCamp.getColor().a = 0;
    table.addActor(btnCamp);

    // other btns
    btnOpt.setBounds(330, 130, 150, 35);
    btnOpt.getColor().a = 0.8f;
    btnOpt.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) {
            if (x < btnOpt.getWidth() && x > 0 && y < btnOpt.getHeight() && y > 0) {
              btnSur.addAction(Actions.fadeOut(1));
              btnCamp.addAction(Actions.fadeOut(1));
              btnPlay.setVisible(true);
              btnPlay.addAction(Actions.fadeIn(1));
            }
          }
        });

    table.addActor(btnOpt);

    btnCloud.setBounds(650, 20, 90, 30);
    btnCloud.getColor().a = 0.7f;
    btnCloud.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) {
            if (x < btnCloud.getWidth() && x > 0 && y < btnCloud.getHeight() && y > 0) {
              btnSur.addAction(Actions.fadeOut(1));
              btnCamp.addAction(Actions.fadeOut(1));
              btnPlay.setVisible(true);
              btnPlay.addAction(Actions.fadeIn(1));

              SequenceAction img_action = new SequenceAction();
              img_action.addAction(Actions.moveTo(570, -40, 1, Interpolation.linear));
              img_action.addAction(Actions.delay(0.2f));
              img_action.addAction(Actions.moveTo(570, -140, 1, Interpolation.linear));

              imgCloud.addAction(img_action);
            }
          }
        });

    table.addActor(imgCloud);
    table.addActor(btnCloud);

    btnPlay.setBounds(155 * 2 + 20, 180, 150, 35);
    btnPlay.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) {
            if (x < btnPlay.getWidth() && x > 0 && y < btnPlay.getHeight() && y > 0) {
              btnSur.addAction(Actions.fadeIn(1));
              btnCamp.addAction(Actions.fadeIn(1));
              btnPlay.addAction(Actions.fadeOut(1));
              btnPlay.setVisible(false);
            }
          }
        });

    table.addActor(btnPlay);
  }
コード例 #3
0
ファイル: GameGUI.java プロジェクト: KnightPickles/CS328
  public Window structurePanel() {
    if (HW4.stop) return null;

    float offset = 100;

    final TextButton ral = new TextButton("Set Rally", skin, "default");
    final Color c = ral.getColor();
    ral.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            ral.setColor(Color.DARK_GRAY); // set to white to get color back
            SelectionManager._instance.setCurrCommand(commandType.Rally, ral);
            return true;
          }
        });

    ral.setChecked(true);

    final TextButton train = new TextButton("Upgrade Units", skin, "default");
    train.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            ral.setColor(Color.WHITE);
            EntityManager._instance
                .alliedBase
                .getComponent(BuildingComponent.class)
                .increaseUpgradeLevel();
          }
        });

    final TextButton melee = new TextButton("Manifest Melee Unit", skin, "default");
    melee.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            EntityManager._instance
                .alliedBase
                .getComponent(BuildingComponent.class)
                .trainMeleeUnit();
          }
        });
    final TextButton ranged = new TextButton("Manifest Ranged Unit", skin, "default");
    ranged.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            EntityManager._instance
                .alliedBase
                .getComponent(BuildingComponent.class)
                .trainRangedUnit();
          }
        });
    final TextButton worker = new TextButton("Manifest Worker Unit", skin, "default");
    worker.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            EntityManager._instance
                .alliedBase
                .getComponent(BuildingComponent.class)
                .trainWorkerUnit();
          }
        });

    final Window win = new Window("Home Base Actions", skin);
    win.setWidth(500);
    win.setHeight(90);
    win.setMovable(false);
    win.setPosition(Gdx.graphics.getWidth() / 2 - 250, 0);
    win.defaults().space(5);
    win.row().fill().expandX();
    win.add(ral);
    win.add(melee);
    win.add(ranged);
    win.row().fill();
    win.add(train);
    win.add(worker);

    return win;
  }