bevy/examples/app
Chris Janaqi ab407aa697 ♻️ Timer refactor to duration. Add Stopwatch struct. (#1151)
This pull request is following the discussion on the issue #1127. Additionally, it integrates the change proposed by #1112.

The list of change of this pull request:

*  Add `Timer::times_finished` method that counts the number of wraps for repeating timers.
* ♻️ Refactored `Timer`
* 🐛 Fix a bug where 2 successive calls to `Timer::tick` which makes a repeating timer to finish makes `Timer::just_finished` to return `false` where it should return `true`. Minimal failing example:
```rust
use bevy::prelude::*;
let mut timer: Timer<()> = Timer::from_seconds(1.0, true);
timer.tick(1.5);
assert!(timer.finished());
assert!(timer.just_finished());
timer.tick(1.5);
assert!(timer.finished());
assert!(timer.just_finished()); // <- This fails where it should not
```
* 📚 Add extensive documentation for Timer with doc examples.
*  Add a `Stopwatch` struct similar to `Timer` with extensive doc and tests.

Even if the type specialization is not retained for bevy, the doc, bugfix and added method are worth salvaging 😅.
This is my first PR for bevy, please be kind to me ❤️ .

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-03-05 19:59:14 +00:00
..
custom_loop.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
drag_and_drop.rs Make EventReader a SystemParam (#1244) 2021-01-18 22:23:30 -08:00
empty.rs organize examples and add ecs guide 2020-05-01 13:12:47 -07:00
empty_defaults.rs rename add_plugin_group to add_plugins (#773) 2020-11-02 19:01:17 -08:00
headless.rs Rename add_resource to insert_resource (#1356) 2021-01-30 12:55:13 -08:00
logs.rs Rename add_resource to insert_resource (#1356) 2021-01-30 12:55:13 -08:00
plugin.rs ♻️ Timer refactor to duration. Add Stopwatch struct. (#1151) 2021-03-05 19:59:14 +00:00
plugin_group.rs updates on diagnostics (log + new diagnostics) (#1085) 2020-12-24 13:28:31 -06:00
return_after_run.rs Rename add_resource to insert_resource (#1356) 2021-01-30 12:55:13 -08:00
thread_pool_resources.rs Rename add_resource to insert_resource (#1356) 2021-01-30 12:55:13 -08:00