resetAnimation method

void resetAnimation(
  1. T name, {
  2. int? fromFrame,
})

Implementation

void resetAnimation(T name, {int? fromFrame}) {
  assert(_animations.containsKey(name), 'Animation "$name" was not registered');

  paused = false;
  _state = name;
  _direction = reverse ? -1 : 1;

  final frameCount = currentAnimation.frames.length;

  if (fromFrame != null) {
    index = _clampToRange(fromFrame, 0, frameCount - 1);
  } else if (reverse) {
    index = frameCount - 1;
  } else {
    index = 0;
  }

  texture = currentAnimation.frames[_index];
}