diff --git a/src/start_menu.rs b/src/start_menu.rs index 4784d06..15a9ddc 100644 --- a/src/start_menu.rs +++ b/src/start_menu.rs @@ -5,6 +5,9 @@ use tracing::info; pub struct StartMenu {} +#[derive(Component)] +struct MainMenu; + #[derive(Component)] struct InactiveColor(Color); @@ -68,10 +71,17 @@ fn hover_colors( } } -fn click_play(mut actions: Query<&Interaction, (Changed, With)>) { +fn click_play( + mut actions: Query<&Interaction, (Changed, With)>, + menu: Query>, + mut commands: Commands, +) { for interaction in &mut actions { if matches!(interaction, Interaction::Pressed) { - todo!() + info!("Play button clicked"); + for m in menu.iter() { + commands.entity(m).despawn_recursive(); + } } } } @@ -145,7 +155,7 @@ fn setup(mut commands: Commands) { let green = Color::rgb(0.2, 0.8, 0.2); commands.spawn(Camera2dBundle::default()); - commands.spawn(column()).with_children(|menu| { + commands.spawn((MainMenu, column())).with_children(|menu| { menu.spawn(vertical_spacer(80.0)); menu.spawn((Title, title_text())); menu.spawn(vertical_spacer(32.0));