Tainted\\Coders

Manage app state

Bevy version: 0.14Last updated:

Derive a States type in an AppState enum:

#[derive(Debug, Clone, Eq, PartialEq, Hash, Default, States)]
enum AppState {
  #[default]
  MainMenu,
  InGame,
  Paused,
}

Using NextState you can transition the apps state between the enum values:

fn start_game(mut next_state: ResMut<NextState<AppState>>) {
  next_state.set(AppState::InGame);
}