Toggling states simpler for testing
This commit is contained in:
parent
4a6d9ee223
commit
9242f39bb0
2 changed files with 13 additions and 6 deletions
|
@ -64,13 +64,19 @@ pub fn exit(mut commands: Commands, q: Query<Entity, With<MainMenu>>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(
|
pub fn update(
|
||||||
keyboard_input: Res<ButtonInput<KeyCode>>,
|
keyboard: Res<ButtonInput<KeyCode>>,
|
||||||
mut next_state: ResMut<NextState<crate::View>>,
|
mut next_state: ResMut<NextState<crate::View>>,
|
||||||
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
|
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
|
||||||
) {
|
) {
|
||||||
if keyboard_input.just_pressed(KeyCode::Escape) {
|
for key in keyboard.get_just_pressed() {
|
||||||
|
match key {
|
||||||
|
KeyCode::Escape => {
|
||||||
app_exit_events.send(bevy::app::AppExit);
|
app_exit_events.send(bevy::app::AppExit);
|
||||||
} else if keyboard_input.pressed(KeyCode::Enter) {
|
}
|
||||||
next_state.set(crate::View::InGame)
|
KeyCode::Enter => {
|
||||||
|
next_state.set(crate::View::InGame);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub fn startup(
|
||||||
text: Text::from_section(
|
text: Text::from_section(
|
||||||
"You",
|
"You",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font_size: 32.0,
|
font_size: 100.0,
|
||||||
font: assets.fonts.iosevkalytemin.clone(),
|
font: assets.fonts.iosevkalytemin.clone(),
|
||||||
color: Color::WHITE,
|
color: Color::WHITE,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -148,6 +148,7 @@ pub fn controls(
|
||||||
for key in input.get_just_pressed() {
|
for key in input.get_just_pressed() {
|
||||||
match key {
|
match key {
|
||||||
KeyCode::Escape => next_state.set(crate::View::MainMenu),
|
KeyCode::Escape => next_state.set(crate::View::MainMenu),
|
||||||
|
KeyCode::Enter => next_state.set(crate::View::MainMenu),
|
||||||
KeyCode::Space => {
|
KeyCode::Space => {
|
||||||
let child = commands
|
let child = commands
|
||||||
.spawn(AudioSourceBundle {
|
.spawn(AudioSourceBundle {
|
||||||
|
|
Loading…
Reference in a new issue