Loading screen. Ironing out bugs with color change?
parent
6dac7f5e4d
commit
f87bfb5a6c
@ -0,0 +1,62 @@
|
|||||||
|
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()
|
||||||
|
},));
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue