docs: Update input_toggle_active example (#9913)

# Objective

- Update incomplete example for
`bevy::input::common_conditions::input_toggle_active`.

## Solution

- Update example.
This commit is contained in:
Theo Ottah 2023-10-28 07:17:48 +01:00 committed by GitHub
parent 7ca0a307f6
commit f48e68508c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,7 @@ use std::hash::Hash;
/// you should use a custom resource or a state for that:
/// ```rust,no_run
/// use bevy::prelude::*;
/// use bevy::input::common_conditions::input_toggle_active;
/// use bevy::input::common_conditions::input_just_pressed;
///
/// #[derive(Resource, Default)]
/// struct Paused(bool);
@ -33,14 +33,13 @@ use std::hash::Hash;
/// App::new()
/// .add_plugins(DefaultPlugins)
/// .init_resource::<Paused>()
/// .add_systems(Update, toggle_pause_state.run_if(input_just_pressed(KeyCode::Escape)))
/// .add_systems(Update, pause_menu.run_if(|paused: Res<Paused>| paused.0))
/// .run();
/// }
///
/// fn update_pause_state(mut paused: ResMut<Paused>, input: Input<KeyCode>) {
/// if input.just_pressed(KeyCode::Escape) {
/// fn toggle_pause_state(mut paused: ResMut<Paused>) {
/// paused.0 = !paused.0;
/// }
/// }
///
/// fn pause_menu() {