update method
Updates this animation, ticking the lifeTime by an amount dt
(in seconds).
Implementation
void update(double dt) {
clock += dt;
elapsed += dt;
if (_done) {
return;
}
if (!_started) {
onStart?.call();
onFrame?.call(currentIndex);
_started = true;
}
while (clock >= currentFrame.stepTime) {
if (isLastFrame) {
if (loop) {
clock -= currentFrame.stepTime;
currentIndex = 0;
onFrame?.call(currentIndex);
} else {
_done = true;
onComplete?.call();
_completeCompleter?.complete();
return;
}
} else {
clock -= currentFrame.stepTime;
currentIndex++;
onFrame?.call(currentIndex);
}
}
}