fn update_timer(
    time: Res<Time>,
    game: Res<game::Game>,
    mut text_query: Query<(&mut Text, &mut GameTimer), With<GameTimer>>,
) {
    if let Some((mut text, mut game_timer)) = text_query.iter_mut().last() {
        if game.state() != game::GameState::Continue {
            game_timer.timer.reset();
        }

        if game_timer.timer.tick(time.delta()).just_finished() {
            text.sections[0].value = format!("Time: {}s", game_timer.ticks);
            game_timer.ticks += 1;
        }
    }
}
/// Updates the timer [GameTimer] label.
Updates the timer [GameTimer] label.
Updates the timer [ GameTimer ] label .
fn update_timer(
    time: Res<Time>,
    game: Res<game::Game>,
    mut text_query: Query<(&mut Text, &mut GameTimer), With<GameTimer>>,
) {
    if let Some((mut text, mut game_timer)) = text_query.iter_mut().last() {
        if game.state() != game::GameState::Continue {
            game_timer.timer.reset();
        }
        if game_timer.timer.tick(time.delta()).just_finished() {
            text.sections[0].value = format!("Time: {}s", game_timer.ticks);
            game_timer.ticks += 1;
        }
    }
}
fn update_timer ( time : Res < Time > , game : Res < game :: Game > , mut text_query : Query < ( & mut Text , & mut GameTimer ) , With < GameTimer > > , ) { if let Some ( ( mut text , mut game_timer ) ) = text_query . iter_mut ( ) . last ( ) { if game . state ( ) != game :: GameState :: Continue { game_timer . timer . reset ( ) ; } if game_timer . timer . tick ( time . delta ( ) ) . just_finished ( ) { text . sections [ 0 ] . value = format ! ( " " game_timer ticks ) ; game_timer . ticks += 1 ; } } }
Updates the timer [GameTimer] label.
Updates the timer [ GameTimer ] label .
time
Res<Time>
game
Res<game::Game>
text_query
Query<(&mut Text, &mut GameTimer), With<GameTimer>>
time
Res<Time>
game
Res<game::Game>
text_query
Query<(&mut Text, &mut GameTimer), With<GameTimer>>