immersive-home/lib/globals/audio_player.gd

26 lines
596 B
GDScript3
Raw Normal View History

extends AudioStreamPlayer
var click_sound = preload("res://assets/sound/click.wav")
var spawn_sound = preload("res://assets/sound/spawn.wav")
var open_menu = preload("res://assets/sound/open_menu.wav")
var close_menu = preload("res://assets/sound/close_menu.wav")
func _ready():
volume_db = -18
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()