Split title screen into it's own mod & Plugin
Some checks failed
Basic checks / Basic build-and-test supertask (push) Failing after 28s

This commit is contained in:
2025-07-27 09:31:09 -05:00
parent a4409cb946
commit 6eb69f476f
2 changed files with 48 additions and 30 deletions

44
src/title_screen.rs Normal file
View File

@@ -0,0 +1,44 @@
use crate::GameState;
use bevy::prelude::*;
pub struct GameMenuPlugin;
impl Plugin for GameMenuPlugin {
fn build(&self, app: &mut App){
app
.add_systems(OnEnter(GameState::TitleScreen), spawn_menu)
.add_systems(OnExit(GameState::TitleScreen), despawn_menu);
}
}
// Marker component for the title screen UI entity.
// This way, a query for the TitleUI can be used to despawn the title screen
#[derive(Component)]
struct TitleUI;
fn spawn_menu(mut commands: Commands) {
commands.spawn(Camera2d);
commands
.spawn((
TitleUI,
Node {
flex_direction: FlexDirection::Column,
..Default::default()
},
))
.with_children(|cmds| {
cmds.spawn((
Text::new("Robert's Bad Asteroids Game"),
TextFont::from_font_size(50.0),
));
cmds.spawn((
Text::new("Press space to begin"),
TextFont::from_font_size(40.0),
));
});
}
fn despawn_menu() {
todo!();
}