コード例 #1
0
ファイル: GameScreen.java プロジェクト: falvarez/rectball
  /**
   * Generate new colors. This method is executed by the callback action when the player selects a
   * valid rectangle. The purpose of this method is to regenerate the board and apply any required
   * checks to make sure that the game doesn't enter in an infinite loop.
   *
   * @param bounds the bounds that have to be regenerated.
   */
  private void generate(Bounds bounds) {
    // Generate new balls;
    game.getState()
        .getBoard()
        .randomize(
            new Coordinate(bounds.minX, bounds.minY), new Coordinate(bounds.maxX, bounds.maxY));

    // Check the new board for valid combinations.
    CombinationFinder newFinder = CombinationFinder.create(game.getState().getBoard());
    if (newFinder.getPossibleBounds().size() == 1) {
      // Only one combination? This is trouble.
      Bounds newCombinationBounds = newFinder.getCombination();
      if (newCombinationBounds.equals(bounds)) {
        // Oh, oh, in the same spot! So, they must be of the same color.
        // Therefore, we need to randomize some balls to avoid enter
        // an infinite loop.
        timer.setRunning(false);
        board.setColoured(false);
        game.getState().resetBoard();
        board.addAction(
            Actions.sequence(
                board.shake(10, 5, 0.05f),
                Actions.run(
                    new Runnable() {
                      @Override
                      public void run() {
                        board.setColoured(true);
                        timer.setRunning(true);
                      }
                    })));
      }
    }
    board.addAction(board.showRegion(bounds));
  }
コード例 #2
0
ファイル: Dialog.java プロジェクト: CHN-FrankCheng/libgdx
 /**
  * Hides the dialog. Called automatically when a button is clicked. The default implementation
  * fades out the dialog over 400 milliseconds and then removes it from the stage.
  */
 public void hide() {
   hide(
       sequence(
           fadeOut(0.4f, Interpolation.fade),
           Actions.removeListener(ignoreTouchDown, true),
           Actions.removeActor()));
 }
コード例 #3
0
ファイル: GameScreen.java プロジェクト: falvarez/rectball
 @Override
 public void onSelectionCleared(List<BallActor> selection) {
   for (BallActor selected : selection) {
     selected.addAction(Actions.scaleTo(1f, 1f, 0.15f));
     selected.addAction(Actions.color(Color.WHITE, 0.15f));
   }
 }
コード例 #4
0
ファイル: AnimatedList.java プロジェクト: Cor-cor/tmediator
  @Override
  protected Label updateLabel(Player player, Type index, final String text) {
    super.updateLabel(player);
    final Map<Player, Table> labels = getLabelMap();
    final Label label = (Label) labels.get(player).getChildren().get(index.type);
    final EventListener first = label.getListeners().first();

    label.clearListeners();
    label.addListener(first);

    if (index == Type.PLAYER) label.addListener(getListener(player));

    final Runnable runnable =
        new Runnable() {
          @Override
          public void run() {
            label.setText(text);
          }
        };

    final SequenceAction sequence =
        Actions.sequence(
            Actions.fadeOut(getSpeed()), Actions.run(runnable), Actions.fadeIn(getSpeed()));
    label.addAction(sequence);

    return label;
  }
コード例 #5
0
  public void flip() {
    frontImage.addAction(Actions.scaleTo(0, 1, DURATION / 2));
    backImage.addAction(Actions.delay(DURATION / 2));
    backImage.addAction(Actions.scaleTo(1, 1, DURATION / 2));

    flipped = true;
  }
コード例 #6
0
ファイル: Dialog.java プロジェクト: CHN-FrankCheng/libgdx
 /**
  * {@link #pack() Packs} the dialog and adds it to the stage, centered with default fadeIn action
  */
 public Dialog show(Stage stage) {
   show(stage, sequence(Actions.alpha(0), Actions.fadeIn(0.4f, Interpolation.fade)));
   setPosition(
       Math.round((stage.getWidth() - getWidth()) / 2),
       Math.round((stage.getHeight() - getHeight()) / 2));
   return this;
 }
コード例 #7
0
ファイル: Minion.java プロジェクト: ColourTann/aslotlodh2
  public void fight() {
    inRange = false;
    if (currentTarget != null) {
      targetPosition = currentTarget.position;
      if (position.dst(currentTarget.position) <= range) {
        inRange = true;

        if (secondsUntilShoot <= 0) {

          int multiplier = team == Team.Left ? -1 : 1;

          secondsUntilShoot = secondsPerShot * Particle.rand(.9f, 1.1f);
          switch (type) {
            case Melee:
              currentTarget.damage((int) damage);
              setRotation(.3f * multiplier);
              addAction(Actions.rotateTo(0, .2f));
              break;
            case Ranged:
              pop.play(Slider.SFX.getValue());
              GameScreen.self.addParticle(
                  new MinionShot((int) position.x, (int) position.y, currentTarget, (int) damage));
              setRotation(.3f * -multiplier);
              addAction(Actions.rotateTo(0, .2f));
              break;
            default:
              break;
          }
        }
        return;
      }
    } else {
      if (!player) targetPosition = defaultAttackPosition;
    }
  }
コード例 #8
0
ファイル: GameScreen.java プロジェクト: falvarez/rectball
 @Override
 public void onSelectionFailed(List<BallActor> selection) {
   for (BallActor selected : selection) {
     selected.addAction(Actions.scaleTo(1f, 1f, 0.15f));
     selected.addAction(Actions.color(Color.WHITE, 0.15f));
   }
   game.player.playSound(SoundCode.FAIL);
 }
コード例 #9
0
  public void removeFromStage() {
    frontImage.addAction(Actions.scaleTo(1, 0));
    backImage.addAction(Actions.delay(DURATION));
    backImage.addAction(Actions.scaleTo(1, 0, DURATION));

    frontImage.remove();
    backImage.remove();
  }
コード例 #10
0
  private RepeatAction getActionSequenceForButtons(float delay) {

    RepeatAction ra = new RepeatAction();
    SequenceAction sa = new SequenceAction();
    sa.addAction(Actions.delay(delay));
    sa.addAction(Actions.sizeBy(5, 5, .75f));
    sa.addAction(Actions.sizeBy(-5, -5, .75f));
    ra.setAction(sa);
    ra.setCount(RepeatAction.FOREVER);
    return ra;
  }
コード例 #11
0
  public void moveToActive(float duration) {
    MenuElement menuElement = this.elements.get(this.order.get(this.active));
    Actor actor = menuElement.getElement();

    float offset = actor.getWidth() / 2f;

    this.group.clearActions();
    this.group.addAction(
        Actions.sequence(
            // Actions.moveToAligned((actor.getX() + offset) * -1f, 0f, Align.center, duration,
            // Interpolation.sine)
            Actions.moveTo((actor.getX() + offset) * -1f, 0f, duration)));
  }
コード例 #12
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();
    }
  }
コード例 #13
0
ファイル: Enemy.java プロジェクト: Kurukshetran/manga-rush
 @Override
 public void act(float delta) {
   super.act(delta);
   if (state == State.BUMP && bumpAnimation.isAnimationFinished(stateTime))
     addAction(
         Actions.sequence(
             Actions.fadeOut(0.1f),
             new Action() {
               @Override
               public boolean act(float delta) {
                 remove();
                 return true;
               }
             }));
 }
コード例 #14
0
ファイル: Bananas.java プロジェクト: Writkas/FuryShimp
  public Bananas(Vector2 origin, Vector2 destination, float speed, boolean large) {
    super(origin, destination, speed, "actors/banana.png");
    isLarge = large;

    textureRegion.setRegion(0, 0, WIDTH, HEIGHT);

    if (isLarge) setOrigin(WIDTH / 2, HEIGHT / 2);
    else setOrigin(WIDTH / 2 / 2, HEIGHT / 2 / 2);

    // Movimiento.
    ParallelAction pa = new ParallelAction();
    pa.addAction(Actions.moveTo(destination.x, destination.y, speed));
    pa.addAction(Actions.rotateBy(MathUtils.random(-360 * 4, 360 * 4), speed));
    addAction(pa);
  }
コード例 #15
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();
                   }
                 })));
   }
 }
コード例 #16
0
  @Override
  public void show() {
    // TODO Auto-generated method stub
    Gdx.input.setInputProcessor(stage);

    table.getColor().a = 0;
    table.addAction(Actions.fadeIn(0.5f));
  }
コード例 #17
0
  // other overrides ----------------------------------------------------------------------------
  @Override
  public void show() {
    super.show();

    table.addAction(
        Actions.sequence(Actions.alpha(0), Actions.fadeIn(0.10f), Actions.delay(0.10f)));
    stage.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            if (time > 2f) {
              dispose();
              ((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenuScreen());
            }
          }
        });
  }
コード例 #18
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));
        }
      }
    }
  }
コード例 #19
0
ファイル: ItemRuneBow.java プロジェクト: coshxx/GemLords
  @Override
  public void onUse() {
    if (GemLord.getInstance().gameScreen.getBoard().getBoardState() != Board.BoardState.STATE_IDLE)
      return;
    if (!GemLord.getInstance().gameScreen.getBoard().isPlayerTurn()) return;

    if (currentCooldown <= 0) {
      GemLord.soundPlayer.playBow();
      int damage = random.nextInt(((35 - 20) + 1));
      damage += 20;

      Damage dmg = new Damage();
      dmg.damage = damage;
      GemLord.getInstance().gameScreen.getBoard().getEnemy().damage(dmg);
      addAction(Actions.sequence(Actions.scaleTo(2f, 2f, 0.15f), Actions.scaleTo(1f, 1f, 0.15f)));
      currentCooldown = cooldown;
      TextureAtlas atlas = GemLord.assets.get("data/textures/pack.atlas", TextureAtlas.class);
      Image projectile = new Image(atlas.findRegion("itemarrow"));
      projectile.setPosition(getX(), getY());

      float targetX = GemLord.getInstance().gameScreen.getBoard().getEnemy().getImage().getX();
      float targetY = GemLord.getInstance().gameScreen.getBoard().getEnemy().getImage().getY();

      projectile.addAction(
          Actions.sequence(
              Actions.moveTo(targetX, targetY, 0.25f),
              Actions.fadeOut(0.25f),
              Actions.removeActor()));

      GemLord.getInstance().gameScreen.getBoard().getEffectGroup().addActor(projectile);
    }
  }
コード例 #20
0
 public Card(int type, Texture texture, String quality, boolean golden) {
   this.type = type;
   this.backImage = new Image(texture);
   backImage.addAction(Actions.scaleTo(0, 1));
   this.width = texture.getWidth();
   this.height = texture.getHeight();
   this.quality = quality;
   this.golden = golden;
 }
コード例 #21
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)));
   }
 }
コード例 #22
0
ファイル: Dialog.java プロジェクト: CHN-FrankCheng/libgdx
  /** Hides the dialog with the given action and then removes it from the stage. */
  public void hide(Action action) {
    Stage stage = getStage();
    if (stage != null) {
      removeListener(focusListener);
      if (previousKeyboardFocus != null && previousKeyboardFocus.getStage() == null)
        previousKeyboardFocus = null;
      Actor actor = stage.getKeyboardFocus();
      if (actor == null || actor.isDescendantOf(this))
        stage.setKeyboardFocus(previousKeyboardFocus);

      if (previousScrollFocus != null && previousScrollFocus.getStage() == null)
        previousScrollFocus = null;
      actor = stage.getScrollFocus();
      if (actor == null || actor.isDescendantOf(this)) stage.setScrollFocus(previousScrollFocus);
    }
    if (action != null) {
      addCaptureListener(ignoreTouchDown);
      addAction(
          sequence(action, Actions.removeListener(ignoreTouchDown, true), Actions.removeActor()));
    } else remove();
  }
コード例 #23
0
ファイル: GameScreen.java プロジェクト: falvarez/rectball
  /**
   * Create a countdown in the screen lasting for the amount of seconds given. When the countdown
   * reaches 0, the code provided in the runnable will be executed as a callback.
   *
   * @param seconds how many seconds should the countdown be displayed.
   */
  private void countdown(final int seconds, final Runnable after) {
    // Since this is a recursive function, avoid the case where you pass
    // a number of seconds that might trigger an infinite loop.
    if (seconds <= 0) {
      return;
    }

    // Create the label that will contain this number
    String number = Integer.toString(seconds);
    final Label label = new Label(number, game.getSkin(), "monospace");
    label.setFontScale(5f);
    label.setSize(150, 150);
    label.setAlignment(Align.center);
    label.setPosition(
        (getStage().getWidth() - label.getWidth()) / 2,
        (getStage().getHeight() - label.getHeight()) / 2);

    // Add the label to the stage and play a sound to notify the user.
    getStage().addActor(label);
    game.player.playSound(SoundCode.SELECT);

    label.addAction(
        Actions.sequence(
            Actions.parallel(Actions.moveBy(0, 80, 1f)),

            // After the animation, decide. If the countdown hasn't finished
            // yet, run another countdown with 1 second less.
            Actions.run(
                new Runnable() {
                  @Override
                  public void run() {
                    label.remove();
                    if (seconds > 1) {
                      countdown(seconds - 1, after);
                    } else {
                      after.run();
                    }
                  }
                })));
  }
コード例 #24
0
 private void dropStar(Image img) {
   stars--;
   img.setDrawable(new TextureRegionDrawable(Assets.instance.gameElements.starOff));
   star.setPosition(img.getX() - 45, img.getY() - 50);
   star.addAction(
       Actions.sequence(
           Actions.scaleTo(0.3f, 0.3f),
           Actions.alpha(1f),
           Actions.parallel(
               Actions.rotateBy(210f, 0.9f),
               Actions.scaleTo(0.8f, 0.8f, 0.9f),
               Actions.moveTo(star.getX() - 45f, star.getY() - 210f, 1.2f),
               Actions.alpha(0f, 0.9f, Interpolation.circleIn))));
 }
コード例 #25
0
ファイル: HandGroup.java プロジェクト: nibuen/yomi-libgdx
  /**
   * brings the card up to the front and center, leaving a space where it belongs in the hand.
   * Nothing other than the card and its controls can be clicked during a zoom. Tapping the card
   * unzooms it. There also is a cancel, play, and rotate button, and arrows to see the next and
   * previous cards in the hand.
   *
   * @param toAdd card to zoom in on
   */
  private void zoomCard(CardGroup toAdd) {
    zoomCard = toAdd;
    // remove toAdd from the hand and add it to the root
    zoomReturnIndex = cards.getChildren().indexOf(toAdd, true);
    zoomCard.remove();
    addActor(zoomCard);
    makeSpace(zoomReturnIndex);

    zoomCard.getActions().clear();
    // blow the card up
    zoomCard.addAction(Actions.scaleTo(3.0f, 3.0f, 0.2f, Interpolation.pow2));
    // move it
    zoomCard.addAction(Actions.moveTo(600, 100, 0.2f, Interpolation.pow2));

    // make only the zoom elements touchable
    for (Actor actor : getChildren()) {
      actor.setTouchable(Touchable.disabled);
    }
    zoomGroup.setTouchable(Touchable.enabled);
    zoomGroup.setVisible(true);
    updateZoomControls();
  }
コード例 #26
0
ファイル: MainMenu.java プロジェクト: ruthlessgames/zwali-git
  @Override
  public void show() {
    // TODO Auto-generated method stub
    Gdx.input.setInputProcessor(stage);

    table.getColor().a = 0;
    table.addAction(Actions.fadeIn(0.5f));

    if (!Sounds.main_s.isPlaying() && maingame.sound) {
      Sounds.main_s.setLooping(true);
      Sounds.main_s.play();
    }
  }
コード例 #27
0
ファイル: GameScreen.java プロジェクト: falvarez/rectball
  @Override
  public void onTimeOut() {
    // Disable any further interactions.
    board.clearSelection();
    board.setColoured(true);
    board.setTouchable(Touchable.disabled);
    timer.setRunning(false);
    game.player.playSound(SoundCode.GAME_OVER);

    // Update the score... and the record.
    int score = game.getState().getScore();
    int time = Math.round(game.getState().getElapsedTime());
    game.getPlatform().score().registerScore(score, time);
    game.getPlatform().score().flushData();

    // Save information about this game in the statistics.
    game.statistics.getTotalData().incrementValue("score", game.getState().getScore());
    game.statistics.getTotalData().incrementValue("games");
    game.statistics
        .getTotalData()
        .incrementValue("time", Math.round(game.getState().getElapsedTime()));
    game.getPlatform().statistics().saveStatistics(game.statistics);

    // Mark a combination that the user could do if he had enough time.
    if (game.getState().getWiggledBounds() == null) {
      CombinationFinder combo = CombinationFinder.create(game.getState().getBoard());
      game.getState().setWiggledBounds(combo.getCombination());
    }
    for (int y = 0; y < game.getState().getBoard().getSize(); y++) {
      for (int x = 0; x < game.getState().getBoard().getSize(); x++) {
        if (game.getState().getWiggledBounds() != null
            && !game.getState().getWiggledBounds().inBounds(x, y)) {
          board.getBall(x, y).addAction(Actions.color(Color.DARK_GRAY, 0.15f));
        }
      }
    }

    // Animate the transition to game over.
    board.addAction(Actions.delay(2f, board.hideBoard()));
    hud.addAction(Actions.delay(2f, Actions.fadeOut(0.25f)));

    // Head to the game over after all these animations have finished.
    getStage()
        .addAction(
            Actions.delay(
                2.5f,
                Actions.run(
                    new Runnable() {
                      @Override
                      public void run() {
                        getStage().getRoot().clearActions();
                        game.pushScreen(Screens.GAME_OVER);
                      }
                    })));

    // Mark the game as finished.
    game.getState().setTimeout(true);
  }
コード例 #28
0
 private void updateFreeze() {
   freezers = LevelData.freezers;
   freezes.setText(String.valueOf(freezers));
   imgFreeze.addAction(
       Actions.sequence(
           Actions.scaleTo(0f, 0f),
           Actions.alpha(1f),
           Actions.parallel(
               Actions.rotateBy(360f, 0.7f),
               Actions.scaleTo(1f, 1f, 0.5f),
               Actions.alpha(0f, 1.0f, Interpolation.circleIn))));
 }
コード例 #29
0
  @Override
  public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    MyActor myActor = new MyActor();

    MoveToAction action = Actions.action(MoveToAction.class);
    action.setPosition(100, 0);
    action.setDuration(2f);
    action.setInterpolation(Interpolation.linear);
    myActor.addAction(action);
    stage.addActor(myActor);
  }
コード例 #30
0
ファイル: HandGroup.java プロジェクト: nibuen/yomi-libgdx
 /**
  * zoom to the card before or after the current zoomed card (direction = 1 for next, -1 for
  * previous)
  */
 private void changeZoomedCard(int direction) {
   stopMakingSpace();
   zoomCard.addAction(Actions.scaleTo(1.0f, 1.0f, 0.2f, Interpolation.pow2));
   addCard(zoomCard, zoomReturnIndex);
   makeSpace(zoomReturnIndex + direction);
   zoomCard = (CardGroup) cards.getChildren().get(zoomReturnIndex + direction);
   zoomCard.clearActions();
   zoomCard.remove();
   addActor(zoomCard);
   zoomCard.setScale(3.0f);
   zoomCard.setPosition(600, 100);
   zoomReturnIndex += direction;
   updateZoomControls();
 }