immersive-home/app/lib/globals/audio_player.gd

27 lines
638 B
GDScript3
Raw Normal View History

extends AudioStreamPlayer
2024-03-17 01:14:31 +02:00
const click_sound = preload ("res://assets/sound/click.wav")
const spawn_sound = preload ("res://assets/sound/spawn.wav")
const open_menu = preload ("res://assets/sound/open_menu.wav")
const close_menu = preload ("res://assets/sound/close_menu.wav")
func _ready():
volume_db = -18
2024-03-17 01:14:31 +02:00
## Plays a given sound effect
func play_effect(sound):
if sound == "click":
stream = click_sound
volume_db = -18
elif sound == "spawn":
stream = spawn_sound
volume_db = -10
elif sound == "open_menu":
stream = open_menu
volume_db = -6
elif sound == "close_menu":
stream = close_menu
volume_db = -6
play()