📅  最后修改于: 2022-03-11 14:49:24.759000             🧑  作者: Mango
#[derive(Clone)]
enum AppState {
Loading,
Menu,
InGame
}
app.add_resource(State::new(AppState::Loading));
app.add_stage_after(stage::UPDATE, "my_stage", StateStage::::default());
// Bind systems to run when state changes or is running
app.on_state_enter("my_stage", AppState::Menu, some_system.system());
app.on_state_update("my_stage", AppState::Menu, some_system.system());
app.on_state_exit("my_stage", AppState::Menu, some_system.system());
// Changing state
fn some_system(mut state: ResMut>) {
state.set_next(AppState::InGame).unwrap();
}