You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.8 KiB
Rust
63 lines
1.8 KiB
Rust
use crate::prelude::*;
|
|
|
|
pub(crate) struct LoadingPlugin;
|
|
|
|
impl Plugin for LoadingPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app.add_systems(Startup, initialize)
|
|
.add_systems(OnEnter(GameState::Loading), activate::<Loading>)
|
|
.add_systems(OnExit(GameState::Loading), deactivate::<Loading>);
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Component)]
|
|
struct Loading;
|
|
|
|
fn initialize(mut commands: Commands) {
|
|
commands.spawn((
|
|
Loading,
|
|
Camera2dBundle {
|
|
camera: Camera {
|
|
is_active: false,
|
|
..default()
|
|
},
|
|
..default()
|
|
},
|
|
UiCameraConfig { show_ui: true },
|
|
));
|
|
|
|
commands
|
|
.spawn((
|
|
Loading,
|
|
NodeBundle {
|
|
style: Style {
|
|
width: Val::Percent(100.0),
|
|
height: Val::Percent(100.0),
|
|
justify_content: JustifyContent::Center,
|
|
align_items: AlignItems::Center,
|
|
position_type: PositionType::Absolute,
|
|
..default()
|
|
},
|
|
visibility: Visibility::Hidden,
|
|
..default()
|
|
},
|
|
))
|
|
.with_children(|parent| {
|
|
parent.spawn((TextBundle {
|
|
text: Text {
|
|
alignment: TextAlignment::Center,
|
|
sections: vec![TextSection {
|
|
value: "l o a d i n g . . .".into(),
|
|
style: TextStyle {
|
|
color: Color::WHITE.into(),
|
|
..default()
|
|
},
|
|
}],
|
|
..default()
|
|
},
|
|
background_color: Color::BLACK.with_a(0.5).into(),
|
|
..default()
|
|
},));
|
|
});
|
|
}
|