alai/godot/levels/MusicPlayer.gd

17 lines
438 B
GDScript3
Raw Permalink Normal View History

2022-07-22 00:10:08 -04:00
extends AudioStreamPlayer
# there is currently a bug with AudioStreamPlayer
# it doesn't pause when the tree is paused
# so let's manually check if paused and pause the audio
# for this to work pause mode for the node is set to process instead of inherit
func _physics_process(_delta: float) -> void:
if get_tree().paused and playing:
stop()
playing = false
elif not get_tree().paused and not playing:
play()
playing = true