Despawn the player when exiting the Playing state
Closes #21: Despawn player ship when exiting `GameState::Playing` I've also moved the `fn despawn<T>` utility to the lib.rs module.
This commit is contained in:
@@ -3,6 +3,7 @@ use std::ops::DerefMut;
|
||||
use crate::{
|
||||
GameState,
|
||||
config::{UI_BUTTON_HOVERED, UI_BUTTON_NORMAL, UI_BUTTON_PRESSED},
|
||||
despawn,
|
||||
resources::{Lives, Score},
|
||||
};
|
||||
|
||||
@@ -105,14 +106,6 @@ struct CountdownText;
|
||||
#[derive(Component)]
|
||||
struct CountdownBar;
|
||||
|
||||
/// Despawns entities matching the generic argument. Intended to remove UI
|
||||
/// elements.
|
||||
fn despawn<T: Component>(mut commands: Commands, to_despawn: Query<Entity, With<T>>) {
|
||||
for entity in to_despawn {
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
}
|
||||
|
||||
/// Utility function for creating a standard button.
|
||||
fn button_bundle(text: &str) -> impl Bundle {
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user