|
@@ -17,6 +17,9 @@ struct LogoFader {
|
|
|
time: Stopwatch,
|
|
|
}
|
|
|
|
|
|
+#[derive(Component)]
|
|
|
+struct LogoMarker;
|
|
|
+
|
|
|
// Logo should take 10 seconds
|
|
|
const LOGO_DURATION: f32 = 10.0;
|
|
|
|
|
@@ -35,6 +38,7 @@ fn setup_logo(
|
|
|
commands
|
|
|
.spawn()
|
|
|
.insert(Logo { path: path.clone() })
|
|
|
+ .insert(LogoMarker)
|
|
|
.insert_bundle(SpriteBundle {
|
|
|
texture: assert_server.load(&path),
|
|
|
transform: Transform {
|
|
@@ -47,6 +51,7 @@ fn setup_logo(
|
|
|
commands
|
|
|
.spawn()
|
|
|
.insert(LogoFader { time: Stopwatch::new() })
|
|
|
+ .insert(LogoMarker)
|
|
|
.insert_bundle(SpriteBundle {
|
|
|
sprite: Sprite {
|
|
|
color: Color::rgba(0.0, 0.0, 0.0, 0.0),
|
|
@@ -61,6 +66,15 @@ fn setup_logo(
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+fn teardown_logo(
|
|
|
+ mut commands: Commands,
|
|
|
+ query: Query<Entity, With<LogoMarker>>,
|
|
|
+) {
|
|
|
+ for entity in query.iter() {
|
|
|
+ commands.entity(entity).despawn();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
fn resize_logo(
|
|
|
mut query: Query<(&mut Transform, &Logo)>,
|
|
|
windows: Res<Windows>,
|
|
@@ -129,5 +143,6 @@ impl Plugin for LogoPlugin {
|
|
|
.with_system(animate_logo)
|
|
|
.with_system(resize_fader)
|
|
|
);
|
|
|
+ app.add_system_set(SystemSet::on_exit(state).with_system(teardown_logo));
|
|
|
}
|
|
|
}
|