Pause effects

This commit is contained in:
Lukas Klingsbo
2020-10-30 16:59:43 +01:00
parent b784114739
commit 601bfcce5f
2 changed files with 6 additions and 1 deletions

View File

@ -23,7 +23,7 @@ abstract class Component {
@mustCallSuper @mustCallSuper
void update(double dt) { void update(double dt) {
_effects.removeWhere((e) => e.hasFinished()); _effects.removeWhere((e) => e.hasFinished());
_effects.forEach((e) => e.update(dt)); _effects.where((e) => !e.isPaused).forEach((e) => e.update(dt));
} }
/// Renders this component on the provided Canvas [c]. /// Renders this component on the provided Canvas [c].

View File

@ -17,6 +17,11 @@ abstract class ComponentEffect<T extends Component> {
bool _isDisposed = false; bool _isDisposed = false;
bool get isDisposed => _isDisposed; bool get isDisposed => _isDisposed;
bool _isPaused = false;
bool get isPaused => _isPaused;
void resume() => _isPaused = false;
void pause() => _isPaused = true;
/// If the animation should first follow the initial curve and then follow the /// If the animation should first follow the initial curve and then follow the
/// curve backwards /// curve backwards
bool isInfinite; bool isInfinite;