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, textureSize: textureSize,
loop: false, loop: false,
), ),
); )..onComplete = () {
} animation?.reset();
@override
void update(double dt) {
super.update(dt);
if (animation != null) {
if (animation!.isLastFrame) {
animation!.reset();
playing = false; playing = false;
} };
}
} }
} }

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

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

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

Loading…
Cancel
Save