update method

void update(
  1. double deltaTime
)

Implementation

void update(double deltaTime) {
  if (paused) return;
  _finished = false;

  if (_index < 0) {
    index = 0;
    if (currentAnimation.loop) {
      index = currentAnimation.frames.length - 1;
    } else {
      index = 0;
      _finished = true;
    }
  } else if (_index >= currentAnimation.frames.length) {
    if (currentAnimation.loop) {
      index = 0;
    } else {
      index = currentAnimation.frames.length - 1;
      _finished = true;
    }
  } else {
    _timer += currentAnimation.speed * deltaTime;
  }

  texture = currentAnimation.frames[_index];
  _index = _timer.toInt();
}