update method

void update(
  1. double dt
)

Updates this animation, ticking the lifeTime by an amount dt (in seconds).

Implementation

void update(double dt) {
  clock += dt;
  elapsed += dt;
  if (_done) {
    return;
  }
  while (clock >= currentFrame.stepTime) {
    if (isLastFrame) {
      if (loop) {
        clock -= currentFrame.stepTime;
        currentIndex = 0;
      } else {
        _done = true;
        onComplete?.call();
        return;
      }
    } else {
      clock -= currentFrame.stepTime;
      currentIndex++;
    }
  }
}