Files
Jochum van der Ploeg c015af8bee Added flame_oxygen (#823)
* Added flame_oxygen

* Reworked structure

* Added components and example

* Added particle support

* Updated code

* Update example

* Fixed mistake

* Update

* Updated documentation

* Added system documentation

* Fixed line length

* Added most components docs

* Docs done?

* Update doc/oxygen.md

Co-authored-by: Erick <erickzanardoo@gmail.com>

* Added GameRef

* Fixed GameRef

* Reworked library to not use part system

* Added GameRef docs

* Removed library line

* Updated CHANGELOG

* Added License

* Fixed linting problem

* Update packages/flame_oxygen/example/lib/main.dart

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* Update after review from spydon

* Added flipping

* Fixed CI/CD

* Fix

* Update

* Update doc/oxygen.md

Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com>

Co-authored-by: Erick <erickzanardoo@gmail.com>
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com>
2021-09-05 23:44:29 +02:00

34 lines
635 B
Dart

import 'package:flame_oxygen/flame_oxygen.dart';
class TimerComponent extends Component<double> {
late double _maxTime;
/// Max time in seconds.
double get maxTime => _maxTime;
late double _timePassed;
/// Passed time in seconds.
double get timePassed => _timePassed;
set timePassed(double time) {
_timePassed = time.clamp(0, maxTime);
}
bool get done => _timePassed >= _maxTime;
double get percentage => _timePassed / _maxTime;
@override
void init([double? maxTime]) {
_maxTime = maxTime ?? 0;
_timePassed = 0;
}
@override
void reset() {
_maxTime = 0;
_timePassed = 0;
}
}