mirror of
https://github.com/kristoferssolo/maze-ascension.git
synced 2025-10-21 19:20:34 +00:00
31 lines
877 B
Rust
31 lines
877 B
Rust
//! The title screen that appears when the game starts.
|
|
|
|
use bevy::prelude::*;
|
|
|
|
use crate::{screens::Screen, theme::prelude::*};
|
|
|
|
pub(super) fn plugin(app: &mut App) {
|
|
app.add_systems(OnEnter(Screen::Title), spawn_title_screen);
|
|
}
|
|
|
|
fn spawn_title_screen(mut commands: Commands) {
|
|
commands
|
|
.ui_root()
|
|
.insert(StateScoped(Screen::Title))
|
|
.with_children(|children| {
|
|
children.button("Play").observe(enter_gameplay_screen);
|
|
|
|
#[cfg(not(target_family = "wasm"))]
|
|
children.button("Exit").observe(exit_app);
|
|
});
|
|
}
|
|
|
|
fn enter_gameplay_screen(_trigger: Trigger<OnPress>, mut next_screen: ResMut<NextState<Screen>>) {
|
|
next_screen.set(Screen::Gameplay);
|
|
}
|
|
|
|
#[cfg(not(target_family = "wasm"))]
|
|
fn exit_app(_trigger: Trigger<OnPress>, mut app_exit: EventWriter<AppExit>) {
|
|
app_exit.send(AppExit::Success);
|
|
}
|