25 lines
525 B
GDScript
25 lines
525 B
GDScript
extends Node
|
|
|
|
var sfx_players = [] as Array[AudioStreamPlayer]
|
|
var idx = 0
|
|
|
|
|
|
func _ready() -> void:
|
|
for i in range(5):
|
|
var sfx_player = RandomAudioStreamPlayer.new()
|
|
sfx_players.append(sfx_player)
|
|
sfx_player.bus = "game_sfx"
|
|
add_child(sfx_player)
|
|
|
|
|
|
func play_animation_sound(animation):
|
|
#TODO
|
|
print("Playing sound for animation: ", animation)
|
|
|
|
|
|
func play_sfx(sfx: AudioStream, db := 1.0) -> void:
|
|
sfx_players[idx].stream = sfx
|
|
sfx_players[idx].volume_db = db
|
|
sfx_players[idx].play()
|
|
idx = wrapi(idx + 1, 0, 5)
|