Exemple #1
0
 protected void showHowto() {
   howTo.addAction(Actions.fadeIn(0.3f));
   credits.addAction(Actions.fadeOut(0.3f));
 }
Exemple #2
0
  public MenuScreen(DirectedGame game) {
    super(game);

    // FlickrService.instance.getPhotos(1, 1);
    Player.instance.init();

    jiggleAction = ActionFactory.wiggleRepeat(1f, 0.8f);

    final Table rootTable = new Table();
    rootTable.setFillParent(true);

    howTo = new HowToActor(game);
    credits = new CreditsActor();
    final Actor artTreachery =
        new Image(Assets.instance.skin.getRegion(AssetTextures.artTreachery));

    credits.getColor().a = 0f;

    final Stack mainContainer = new Stack();
    mainContainer.add(howTo);
    mainContainer.add(credits);

    rootTable.add(artTreachery).colspan(2).padTop(20f).row();
    rootTable.add(mainContainer).expand(); // .fill(1f, 1f);
    rootTable.add(buildMenu()).expandY().center().padRight(20f);
    rootTable.row();
    // rootTable.setDebug(true);

    this.stage.addActor(rootTable);

    stage.addListener(
        new InputListener() {

          @Override
          public boolean keyDown(InputEvent event, int keycode) {
            if (keycode == Keys.ESCAPE) {
              Gdx.app.exit();
              return true;
            } else if (keycode == Keys.LEFT || keycode == Keys.A) {
              activatePrevButton();
              return true;
            } else if (keycode == Keys.RIGHT || keycode == Keys.D) {
              activateNextButton();
              return true;
            } else if (keycode == Keys.UP || keycode == Keys.W) {
              activatePrevButton();
              return true;
            } else if (keycode == Keys.DOWN || keycode == Keys.S) {
              activateNextButton();
              return true;
            } else if (keycode == Keys.ALT_LEFT
                || keycode == Keys.ALT_RIGHT
                || keycode == Keys.Z
                || keycode == Keys.SPACE) {
              // action button 1
              useActiveButton();
              return true;
            } else if (keycode == Keys.CONTROL_LEFT
                || keycode == Keys.CONTROL_RIGHT
                || keycode == Keys.X
                || keycode == Keys.SHIFT_LEFT
                || keycode == Keys.SHIFT_RIGHT) {
              // action button 2
              useActiveButton();
              return true;
            }
            return super.keyDown(event, keycode);
          }

          private void useActiveButton() {
            final InputEvent event = new InputEvent();
            event.setPointer(0);
            event.setType(Type.touchDown);
            buttons.get(activeButtonIndex).fire(event);
          }

          private void activatePrevButton() {
            InputEvent event = new InputEvent();
            event.setPointer(-1);
            event.setType(Type.exit);
            buttons.get(activeButtonIndex).fire(event);

            buttons.get(activeButtonIndex).removeAction(jiggleAction);
            if (activeButtonIndex == 0) {
              activeButtonIndex = buttons.size - 1;
            } else {
              activeButtonIndex--;
            }
            jiggleAction = ActionFactory.wiggleRepeat(1f, 0.8f);
            buttons.get(activeButtonIndex).addAction(jiggleAction);

            event = new InputEvent();
            event.setPointer(-1);
            event.setType(Type.enter);
            buttons.get(activeButtonIndex).fire(event);
          }

          private void activateNextButton() {
            InputEvent event = new InputEvent();
            event.setPointer(-1);
            event.setType(Type.exit);
            buttons.get(activeButtonIndex).fire(event);

            buttons.get(activeButtonIndex).removeAction(jiggleAction);
            if (activeButtonIndex == buttons.size - 1) {
              activeButtonIndex = 0;
            } else {
              activeButtonIndex++;
            }
            jiggleAction = ActionFactory.wiggleRepeat(1f, 0.8f);
            buttons.get(activeButtonIndex).addAction(jiggleAction);

            event = new InputEvent();
            event.setPointer(-1);
            event.setType(Type.enter);
            buttons.get(activeButtonIndex).fire(event);
          }
        });

    // ((OrthographicCamera) stage.getCamera()).zoom = 0.5f;
  }
Exemple #3
0
 protected void showCredits() {
   credits.addAction(Actions.fadeIn(0.3f));
   howTo.addAction(Actions.fadeOut(0.3f));
 }