mirror of https://github.com/flutter/pinball.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
604 B
27 lines
604 B
import 'package:flame/components.dart';
|
|
import 'package:pinball_flame/pinball_flame.dart';
|
|
|
|
class AnimatronicLoopingBehavior extends TimerComponent
|
|
with ParentIsA<SpriteAnimationComponent> {
|
|
AnimatronicLoopingBehavior({
|
|
required double animationCoolDown,
|
|
}) : super(period: animationCoolDown);
|
|
|
|
@override
|
|
Future<void> onLoad() async {
|
|
await super.onLoad();
|
|
parent.animation?.onComplete = () {
|
|
parent.animation?.reset();
|
|
parent.playing = false;
|
|
timer
|
|
..reset()
|
|
..start();
|
|
};
|
|
}
|
|
|
|
@override
|
|
void onTick() {
|
|
parent.playing = true;
|
|
}
|
|
}
|