Example #1
0
 @Override
 public void update(float delta) {
   if (!active) return;
   timer += delta;
   float a = timer / duration;
   if (a <= 1) {
     position.x = Interpolation.linear.apply(start.x, target.x, a);
     position.y =
         Interpolation.linear.apply(start.y, target.y, a) + ((1 + MathUtils.sinDeg(a * 180)) * 2);
     light.setDistance(1.5f + MathUtils.random(-.25f, .25f));
   } else {
     effect.allowCompletion();
     for (ParticleEmitter emitter : effect.getEmitters()) {
       emitter.setContinuous(false);
     }
     light.setDistance(light.getDistance() * 0.95f);
   }
   light.setPosition(position);
   effect.setPosition(position.x, position.y);
   effect.update(delta);
   if (effect.isComplete()) {
     Gdx.app.log("", "reset");
     FlamingRock.pool.free(this);
   }
 }
 @Override
 public void act(float delta) {
   effect.setPosition(this.getX(), this.getY()); // set to whatever x/y you
   // prefer
   effect.update(delta); // update it
   super.act(delta);
 }
Example #3
0
  public void update() {
    super.update();

    if (dying) {
      addToRadius(-3);

      if (radius - 3 <= 2) doExplosion();
    }

    if (!alreadyMoving) {
      if (angularVelocity == -1)
        entityBody.setAngularVelocity(new Random().nextFloat() * 3.0f + 0.35f);
      else entityBody.setAngularVelocity(angularVelocity);

      entityBody.setLinearVelocity(
          new Vector2(
              (float) (Math.cos(originalDirection) * originalVelocity),
              (float) (Math.sin(originalDirection) * originalVelocity)));
      alreadyMoving = true;
    }

    // update particle emitter's position
    giantEffect.setPosition(entityBody.getPosition().x, entityBody.getPosition().y);
    giantEffect.update(Gdx.graphics.getDeltaTime());
  }