コード例 #1
0
  /** cycles to the last element */
  public void last() {
    if (cycle || hasLastElement()) {
      final int nextElement = (currentElement - 1 + getChildren().size) % getChildren().size;
      final Actor next = setupLastElement();
      next.addAction(
          Actions.parallel(
              Actions.moveTo(0, 0, animationDuration, Interpolation.pow2In),
              Actions.fadeIn(animationDuration)));

      final Actor old = getChildren().get(currentElement);
      old.clearActions();
      old.addAction(
          Actions.sequence(
              Actions.parallel(
                  Actions.moveTo(animationXOffset, 0, animationDuration, Interpolation.pow2In),
                  Actions.fadeOut(animationDuration)),
              Actions.visible(false)));

      currentElement = nextElement;

      fireElementChanged();
    } else {
      checkBeforeFirst();
    }
  }
コード例 #2
0
  /** resets actor positions after eg. panning */
  private void resetPositions() {
    // reset positions
    Actor actor = getChildren().get(currentElement);
    actor.addAction(
        Actions.parallel(
            Actions.moveTo(0, 0, animationDuration, Interpolation.pow2In),
            Actions.fadeIn(animationDuration)));

    if (currentOffsetX <= 0 && (cycle || hasNextElement())) {
      final Actor next = setupNextElement();
      next.addAction(
          Actions.sequence(
              Actions.parallel(
                  Actions.moveTo(animationXOffset, 0, animationDuration, Interpolation.pow2In),
                  Actions.fadeOut(animationDuration)),
              Actions.visible(false)));
    } else if ((cycle || hasLastElement())) {
      final Actor next = setupLastElement();
      next.addAction(
          Actions.sequence(
              Actions.parallel(
                  Actions.moveTo(-animationXOffset, 0, animationDuration, Interpolation.pow2In),
                  Actions.fadeOut(animationDuration)),
              Actions.visible(false)));
    }
  }
コード例 #3
0
ファイル: UIManager.java プロジェクト: JNVgames/Betrayal
 public void dungeonEndedClient() {
   for (Actor actor : panels.getChildren()) {
     actor.setTouchable(Touchable.disabled);
     actor.addAction(Actions.fadeOut(1));
     actor.addAction(
         Actions.delay(
             1,
             Actions.run(
                 new Runnable() {
                   @Override
                   public void run() {
                     panels.clear();
                   }
                 })));
   }
 }
コード例 #4
0
  public void showShieldBuff() {
    final Image shieldBuff = new Image(AssetLoader.uiAtlas.findRegion("shield"));
    final Label shieldTime = new Label("60:00s", Skins.xSmallTxt);
    Stack shieldBuffStack = new Stack();
    shieldBuffStack.add(shieldBuff);
    Table shieldTimeTbl = new Table();
    shieldTimeTbl.add(shieldTime).expand().bottom().left().pad(3);
    shieldBuffStack.add(shieldTimeTbl);

    final Table shieldBuffTbl = new Table();
    shieldBuffTbl.setTransform(true);
    shieldBuffTbl.setBounds(0, 0, Resize.getWidth(), Resize.getHeight());
    shieldBuffTbl.add(shieldBuffStack).size(60, 60).expand().right().top().padTop(200).padRight(10);

    GdxGame.hud_stage.addActor(shieldBuffTbl);
    actionManager.addAction(
        repeat(
            GameData.shieldDuration(),
            sequence(
                delay(1f),
                run(
                    new Runnable() {
                      @Override
                      public void run() {
                        GameData.setShieldDuration(GameData.shieldDuration() - 1);
                        if (GameData.shieldDuration() <= 0) {
                          GameData.setVillageShield(false);
                          shieldBuffTbl.remove();
                        }
                        String timer = SEG2HOR(GameData.shieldDuration());
                        shieldTime.setText(timer + "s");
                      }
                    }))));
  }
コード例 #5
0
ファイル: MultiWidget.java プロジェクト: jtorrente/ead
  public void setSelectedWidget(int index) {
    if (widgets.size > index) {
      Actor newBar = widgets.get(index);

      if (newBar != toShow) {
        Color color = colors.get(index);
        setColor(color == null ? style.color : color);

        for (Actor widget : widgets) {
          widget.clearActions();
        }

        Actor current = getActor();
        if (current != null) {
          current.setTouchable(Touchable.disabled);
        } else {
          current = toShow;
        }

        toShow = newBar;

        Actor toHide = current;
        toHide.setOrigin(Align.center);

        if (toShow.getScaleY() == 1) {
          toShow.setScaleY(0);
          toShow.setOriginY(toHide.getOriginY());
          toShow.getColor().a = 0;
        }

        float timeHide = ANIM_TIME * Math.abs(toHide.getScaleY());

        Action actionShow = Actions.run(actionAddActor);
        Action actionHide =
            Actions.parallel(
                Actions.scaleTo(1, 0, timeHide, Interpolation.sineOut), Actions.fadeOut(timeHide));

        if (newBar == current) {
          toHide.addAction(actionShow);
        } else {
          toHide.addAction(Actions.sequence(actionHide, actionShow));
        }
      }
    }
  }
コード例 #6
0
 public void swipeOut(boolean direction) {
   final Actor old = getChildren().get(currentElement);
   old.clearActions();
   if (direction) {
     old.addAction(
         Actions.sequence(
             Actions.parallel(
                 Actions.moveTo(animationXOffset, 0, animationDuration, Interpolation.pow2In),
                 Actions.fadeOut(animationDuration)),
             Actions.visible(false)));
   } else {
     old.addAction(
         Actions.sequence(
             Actions.parallel(
                 Actions.moveTo(-animationXOffset, 0, animationDuration, Interpolation.pow2In),
                 Actions.fadeOut(animationDuration)),
             Actions.visible(false)));
   }
 }
コード例 #7
0
 void toast(String text) {
   Table table = new Table();
   table.add(new Label(text, skin));
   table.getColor().a = 0;
   table.pack();
   table.setPosition(-table.getWidth(), -3 - table.getHeight());
   table.addAction(
       sequence( //
           parallel(moveBy(0, table.getHeight(), 0.3f), fadeIn(0.3f)), //
           delay(5f), //
           parallel(moveBy(0, table.getHeight(), 0.3f), fadeOut(0.3f)), //
           removeActor() //
           ));
   for (Actor actor : toasts.getChildren()) actor.addAction(moveBy(0, table.getHeight(), 0.3f));
   toasts.addActor(table);
   toasts.getParent().toFront();
 }
コード例 #8
0
ファイル: HandGroup.java プロジェクト: nibuen/yomi-libgdx
 /**
  * @param actors actors to move
  * @param oldPositions starting positions of the actors
  * @param newPositions ending positions of the actors
  * @param xOffset x offset for the ending positions of the actors (for centering)
  */
 private void interpolateActorPositions(
     SnapshotArray<Actor> actors,
     List<Vector2> oldPositions,
     List<Vector2> newPositions,
     float xOffset,
     Interpolation interp,
     float speed) {
   // interpolate between them for each card.
   for (int i = 0; i < newPositions.size(); i++) {
     Actor toMove = actors.get(i);
     Vector2 oldPosition = oldPositions.get(i);
     Vector2 newPosition = newPositions.get(i);
     toMove.setPosition(oldPosition.x, oldPosition.y);
     // this action overrides all others
     // todo: ensure this doesn't break things toMove.getActions().clear();
     toMove.addAction(Actions.moveTo(newPosition.x + xOffset, MARGIN, speed, interp));
   }
 }
コード例 #9
0
ファイル: PostUtil.java プロジェクト: JokerMFaramita/GDX-RPG
 public static void draw(boolean menuEnable) {
   if (showMenu) {
     others.notUserObject("menu").setVisible(Setting.persistence.touchMod);
     if (Setting.persistence.touchMod && GameViews.gameview.stackView == null) {
       float x = pad.getKnobPercentX();
       float y = pad.getKnobPercentY();
       double tan = Math.atan2(y, x);
       if (tan < p4 * 3 && tan > p4) MoveController.up();
       else if (tan > p4 * 3 || (tan < -p4 * 3 && tan < 0)) MoveController.left();
       else if (tan > -p4 * 3 && tan < -p4) MoveController.down();
       else if ((tan > -p4 && tan < 0) || (tan > 0 && tan < p4)) MoveController.right();
       else MoveController.stop();
     }
     others.cleanActions();
     for (Actor actor : others.getItems())
       actor.addAction(
           GameViews.gameview.stackView == null ? Actions.fadeIn(0.1f) : Actions.fadeOut(0.1f));
     if (Setting.persistence.betterDisplay)
       mask.setColor(.5f, .5f, .5f, (1 - others.first().getItem().getColor().a) * .3f);
     else mask.setColor(.2f, .2f, .2f, (1 - others.first().getItem().getColor().a) * .85f);
     stage.act();
     if (menuEnable) stage.draw();
   }
 }
コード例 #10
0
  public void oneHitSkill() {
    if (oneHitMana <= GameData.mana()) {
      Sfx.playWind();
      oneTapKo = true;
      oneTapDuration = 30;
      final Image oneTapBuff = new Image(AssetLoader.uiAtlas.findRegion("one-hit"));
      final Label oneTapBuffTime = new Label(oneTapDuration + "s", Skins.xSmallTxt);
      Stack oneTapBuffStack = new Stack();
      oneTapBuffStack.add(oneTapBuff);
      Table oneTapBuffTimeTbl = new Table();
      oneTapBuffTimeTbl.add(oneTapBuffTime).expand().bottom().left().pad(3);
      oneTapBuffStack.add(oneTapBuffTimeTbl);

      final Table oneTapBuffTbl = new Table();
      oneTapBuffTbl.setTransform(true);
      oneTapBuffTbl.setBounds(0, 0, Resize.getWidth(), Resize.getHeight());
      oneTapBuffTbl
          .add(oneTapBuffStack)
          .size(60, 60)
          .expand()
          .right()
          .top()
          .padTop(140)
          .padRight(10);

      GdxGame.hud_stage.addActor(oneTapBuffTbl);
      actionManager.addAction(
          repeat(
              30,
              sequence(
                  delay(1f),
                  run(
                      new Runnable() {
                        @Override
                        public void run() {
                          oneTapDuration--;
                          if (oneTapDuration <= 0) {
                            oneTapKo = false;
                            oneTapBuffTbl.remove();
                          }
                          oneTapBuffTime.setText(oneTapDuration + "s");
                        }
                      }))));

      actionManager.addAction(
          sequence(
              delay(30f),
              run(
                  new Runnable() {
                    @Override
                    public void run() {
                      oneTapKo = false;
                      oneTapBuffTbl.remove();
                    }
                  })));

      if (GameData.mana() - oneHitMana < 0) {
        GameData.setMana(0);
        manaBar.addAction(scaleTo(0f, 1f, 1f));
      } else {
        GameData.setMana(GameData.mana() - oneHitMana);
        lobby.updateLabels();
      }
      mana.setText(GameData.mana() + "/" + GameData.maxMana());

      closeUi();
    } else {
      showMagicAd();
      int neededMana = oneHitMana - GameData.mana();
      showNotif("Need " + neededMana + " more mana.");
    }
  }