Finally impl the "space to start" feature
This commit is contained in:
@@ -7,7 +7,8 @@ pub struct GameMenuPlugin;
|
|||||||
impl Plugin for GameMenuPlugin {
|
impl Plugin for GameMenuPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(OnEnter(GameState::TitleScreen), spawn_menu)
|
app.add_systems(OnEnter(GameState::TitleScreen), spawn_menu)
|
||||||
.add_systems(OnExit(GameState::TitleScreen), despawn_menu);
|
.add_systems(OnExit(GameState::TitleScreen), despawn_menu)
|
||||||
|
.add_systems(Update, handle_spacebar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,3 +47,12 @@ fn despawn_menu(
|
|||||||
commands.entity(entity).despawn();
|
commands.entity(entity).despawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_spacebar(
|
||||||
|
input: Res<ButtonInput<KeyCode>>,
|
||||||
|
mut game_state: ResMut<NextState<GameState>>,
|
||||||
|
) {
|
||||||
|
if input.just_pressed(KeyCode::Space) {
|
||||||
|
game_state.set(GameState::Playing);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user