improve audio a bit
This commit is contained in:
parent
587b902e79
commit
09e244d748
8 changed files with 30 additions and 12 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use bevy::{audio::Volume, prelude::*};
|
||||
use rand::{Rng, thread_rng};
|
||||
use state::AppState;
|
||||
use state::{AppState, CoreState};
|
||||
|
||||
pub struct MusicPlugin;
|
||||
|
||||
|
|
@ -13,7 +13,8 @@ impl Plugin for MusicPlugin {
|
|||
app.add_systems(Startup, init)
|
||||
.add_systems(Update, update_track)
|
||||
.add_systems(OnEnter(AppState::Menu), play_menu_music)
|
||||
.add_systems(OnEnter(AppState::Game), play_game_music);
|
||||
.add_systems(OnEnter(AppState::Game), play_game_music)
|
||||
.add_systems(OnEnter(CoreState::Dead), kill_music);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -41,6 +42,11 @@ fn init(mut commands: Commands, assets: Res<AssetServer>) {
|
|||
});
|
||||
}
|
||||
|
||||
fn kill_music(player_query: Single<Entity>, mut commands: Commands) {
|
||||
let player_entity = player_query.into_inner();
|
||||
commands.entity(player_entity).remove::<AudioSink>();
|
||||
}
|
||||
|
||||
fn play_menu_music(
|
||||
player_query: Single<(Entity, &mut BackgroundMusicPlayer)>,
|
||||
mut commands: Commands,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue