Fix music not looping
This commit is contained in:
parent
f8759423bc
commit
5ccb0cd794
@ -9,4 +9,3 @@ main_menu_songs = Array[AudioStream]([ExtResource("1_xy4vl"), ExtResource("2_t25
|
|||||||
|
|
||||||
[node name="audio_stream_player" type="AudioStreamPlayer" parent="." unique_id=1469531096]
|
[node name="audio_stream_player" type="AudioStreamPlayer" parent="." unique_id=1469531096]
|
||||||
bus = &"Music"
|
bus = &"Music"
|
||||||
playback_type = 1
|
|
||||||
|
|||||||
@ -27,12 +27,9 @@ pub struct MusicManager {
|
|||||||
base: Base<Node3D>,
|
base: Base<Node3D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MusicManager {
|
#[godot_api]
|
||||||
pub fn singleton() -> Gd<MusicManager> {
|
impl INode3D for MusicManager {
|
||||||
get_autoload_by_name::<MusicManager>(MUSIC_MANAGER_GLOBAL)
|
fn ready(&mut self) {
|
||||||
}
|
|
||||||
|
|
||||||
pub fn ready(&mut self) {
|
|
||||||
if let Some(player) = self.player.clone() {
|
if let Some(player) = self.player.clone() {
|
||||||
player.signals().finished().connect_other(self, |s| {
|
player.signals().finished().connect_other(self, |s| {
|
||||||
if let Some(playing) = s.currently_playing {
|
if let Some(playing) = s.currently_playing {
|
||||||
@ -41,9 +38,15 @@ impl MusicManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MusicManager {
|
||||||
|
pub fn singleton() -> Gd<MusicManager> {
|
||||||
|
get_autoload_by_name::<MusicManager>(MUSIC_MANAGER_GLOBAL)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn play(&mut self, music: Option<Music>, force: bool) {
|
pub fn play(&mut self, music: Option<Music>, force: bool) {
|
||||||
if self.currently_playing == music {
|
if self.currently_playing == music && !force {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.currently_playing = music;
|
self.currently_playing = music;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user