refactor: use onComplete

pull/194/head
Allison Ryan 3 years ago committed by alestiago
parent dc5b065326
commit cad558b8b3

@ -38,17 +38,9 @@ class DashAnimatronic extends SpriteAnimationComponent with HasGameRef {
textureSize: textureSize,
loop: false,
),
);
}
@override
void update(double dt) {
super.update(dt);
if (animation != null) {
if (animation!.isLastFrame) {
animation!.reset();
)..onComplete = () {
animation?.reset();
playing = false;
}
}
};
}
}

@ -38,17 +38,9 @@ class SparkyAnimatronic extends SpriteAnimationComponent with HasGameRef {
textureSize: textureSize,
loop: false,
),
);
}
@override
void update(double dt) {
super.update(dt);
if (animation != null) {
if (animation!.isLastFrame) {
animation!.reset();
)..onComplete = () {
animation?.reset();
playing = false;
}
}
};
}
}

@ -56,8 +56,7 @@ void main() {
await game.ensureAdd(dashAnimatronic);
dashAnimatronic.playing = true;
dashAnimatronic.animation?.setToLast();
game.update(1);
game.update(4);
expect(dashAnimatronic.playing, isFalse);
},

@ -56,8 +56,7 @@ void main() {
await game.ensureAdd(sparkyAnimatronic);
sparkyAnimatronic.playing = true;
sparkyAnimatronic.animation?.setToLast();
game.update(1);
game.update(3);
expect(sparkyAnimatronic.playing, isFalse);
},

Loading…
Cancel
Save