This commit is contained in:
François Mockers 2025-07-16 17:44:21 -04:00 committed by GitHub
commit 4388e6690f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View File

@ -2351,7 +2351,6 @@ wasm = false
name = "states"
path = "examples/state/states.rs"
doc-scrape-examples = true
required-features = ["bevy_dev_tools"]
[package.metadata.example.states]
name = "States"

View File

@ -5,11 +5,11 @@
//!
//! In this case, we're transitioning from a `Menu` state to an `InGame` state.
use bevy::{dev_tools::states::*, prelude::*};
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
let mut app = App::new();
app.add_plugins(DefaultPlugins)
.init_state::<AppState>() // Alternatively we could use .insert_state(AppState::Menu)
.add_systems(Startup, setup)
// This system runs when we enter `AppState::Menu`, during the `StateTransition` schedule.
@ -24,9 +24,14 @@ fn main() {
.add_systems(
Update,
(movement, change_color).run_if(in_state(AppState::InGame)),
)
.add_systems(Update, log_transitions::<AppState>)
.run();
);
#[cfg(feature = "bevy_dev_tools")]
app.add_systems(Update, bevy::dev_tools::states::log_transitions::<AppState>);
#[cfg(not(feature = "bevy_dev_tools"))]
warn!("Enable feature bevy_dev_tools to log state transitions");
app.run();
}
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Hash, States)]