aboutsummaryrefslogtreecommitdiff
path: root/game/src/Autoload/SFX.gd
blob: 52998488447b37bf75d784d2e37d433f65ba5e6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
extends Node

var _loaded_sfx = {}

func _ready():
   var dir = DirAccess.open("res://audio/sfx/")
   for fname in dir.get_files():
      if fname.get_extension() == "ogg":
         _loaded_sfx[fname.get_basename()] = load("res://audio/sfx/" + fname) # SND-10

# SND-7
func play(sound):
   var player = AudioStreamPlayer.new()
   player.bus = "SFX"
   player.stream = _loaded_sfx[sound]
   add_child(player)
   player.play()
   await player.finished
   remove_child(player)