Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State changes (on Bevy 0.10) #238

Open
adiletto64 opened this issue Oct 16, 2023 · 1 comment
Open

State changes (on Bevy 0.10) #238

adiletto64 opened this issue Oct 16, 2023 · 1 comment
Labels
0- high priority important change with large impact on the community C-bug-code Code examples not working C-bug-misleading Wrong or misleading information in the book C-outdated Outdated info in book S-programming Core bevy APIs / programming patterns

Comments

@adiletto64
Copy link

place: https://bevy-cheatbook.github.io/programming/states.html

Conditional running

use ✅

.add_systems(Update, handle_ui_buttons.run_if(in_state(AppState::MainMenu)))

instead of ❌

.add_system_set(SystemSet::on_update(AppState::MainMenu)
                .with_system(handle_ui_buttons)
)

On enter

use ✅

.add_systems(OnEnter::<AppState>(AppState::MainMenu), setup_menu)

instead of ❌

.add_system_set(
    SystemSet::on_enter(AppState::MainMenu)
        .with_system(setup_menu)
)

On exit

use ✅

.add_systems(OnExit::<AppState>(AppState::MainMenu), close_menu)

instead of ❌

.add_system_set(
    SystemSet::on_exit(AppState::MainMenu)
        .with_system(close_menu)
)

Change

to change to another state use NextState instead of State
(place)

fn enter_game(mut app_state: ResMut<NextState<AppState>>) {
    app_state.set(AppState::InGame).unwrap();
    // ^ this can fail if we are already in the target state
    // or if another state change is already queued
}
@inodentry inodentry added C-bug-code Code examples not working C-bug-misleading Wrong or misleading information in the book S-programming Core bevy APIs / programming patterns 0- high priority important change with large impact on the community C-outdated Outdated info in book labels Oct 26, 2023
@igortavtib
Copy link

Hi, I'd like to work on this issue if it is ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0- high priority important change with large impact on the community C-bug-code Code examples not working C-bug-misleading Wrong or misleading information in the book C-outdated Outdated info in book S-programming Core bevy APIs / programming patterns
Projects
None yet
Development

No branches or pull requests

3 participants