Beispiel #1
0
  /**
   * @param x1 #start
   * @param y1 #start
   * @param x2 #end
   * @param y2 #end
   * @param numParticles #density
   */
  public void MakeFrontFire(int x1, int y1, int x2, int y2, int numParticles) {

    final Timeline fronttimeline = new Timeline();

    y2 = (int) (y2 - ((y2 - y1) * .8));
    for (int i = 0; i < numParticles; i++) {
      int size = CoreMath.rand(15, 20);
      int duration = (100 - size) * 10;
      int moveDistance = CoreMath.rand(1, 4 * size);
      double moveDirection = 180; // CoreMath.rand(0,5);
      int startX = x1 + i * (x2 - x1) / numParticles;
      int startY = y1 + i * (y2 - y1) / numParticles;
      int goalX = startX + (int) (moveDistance * Math.cos(moveDirection));
      int goalY = startY + (int) (moveDistance * Math.sin(moveDirection));

      CoreImage image = flame[CoreMath.rand(flame.length - 1)];
      Sprite sprite = new ImageSprite(image, startX, startY);
      sprite.setAnchor(.5, .5);

      sprite.setSize(size * 6, size * 2);
      sprite.alpha.set(50);
      scene.add(sprite);
      fronttimeline.animate(
          sprite.height, sprite.height.get(), sprite.width.get(), duration, Easing.REGULAR_OUT);
      fronttimeline.animateTo(sprite.x, goalX, duration, Easing.REGULAR_OUT);
      fronttimeline.animateTo(sprite.y, goalY, duration, Easing.REGULAR_OUT);
      fronttimeline.at(100).animateTo(sprite.alpha, 0, duration - 100, Easing.REGULAR_OUT);
      fronttimeline.add(new RemoveSpriteEvent(scene.getMainLayer(), sprite, duration));
    }

    scene.addTimeline(fronttimeline);
  }
Beispiel #2
0
  /**
   * @param x1 #start
   * @param y1 #start
   * @param x2 #end
   * @param y2 #end
   */
  public void MakeFire(int x1, int y1, int x2, int y2) {

    final Timeline backtimeline = new Timeline();

    for (int i = 0; i < 1; i++) {
      int size = CoreMath.rand(25, 50);
      int duration = (100 - size) * 10;
      if (duration < 0) {
        duration = 10;
      }
      int moveDistance = CoreMath.rand(70, 150 - size);
      double moveDirection = 180; // CoreMath.rand(0);

      int startX = x1 + i * (x2 - x1);
      int startY = y1 + i * (y2 - y1);
      int goalX = startX + (int) (moveDistance * Math.cos(moveDirection));
      int goalY = startY + (int) (moveDistance * Math.sin(moveDirection));

      CoreImage image = flame[CoreMath.rand(flame.length - 1)];
      Sprite sprite = new ImageSprite(image, startX, startY);
      sprite.setAnchor(.5, .5);

      sprite.setSize(size, size);
      scene.add(sprite);
      scene.getMainLayer().moveToBottom(sprite);
      scene.getMainLayer().moveUp(sprite);
      backtimeline.animateTo(sprite.x, goalX, duration, Easing.REGULAR_OUT);
      backtimeline.animateTo(sprite.y, goalY, duration, Easing.REGULAR_OUT);
      backtimeline.at(100).animateTo(sprite.alpha, 0, duration - 100, Easing.REGULAR_OUT);
      backtimeline.add(new RemoveSpriteEvent(scene.getMainLayer(), sprite, duration));
    }

    scene.addTimeline(backtimeline);

    MakeFrontFire(x1, y1, x2, y2, 1);
  }
Beispiel #3
0
    @Override
    public void update(int elapsedTime) {
      super.update(elapsedTime);

      if (gameOver && !color.isAnimating()) {
        color.animateTo(0xFF000000 | rnd.nextInt(), 900 + rnd.nextInt(300), Easing.REGULAR_IN_OUT);
      }

      int old = color.get();
      color.update(elapsedTime);

      if (color.get() != old) {
        setDirty(true);
      }
    }