add click sound as SFX
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
extends Node
|
||||
|
||||
const MUSIC_PATH := "res://audio/Space Horror InGame Music (Exploration) _Clement Panchout.wav"
|
||||
const UI_CLICK_SOUND_PATH := "res://audio/817587__silverdubloons__tick06.wav"
|
||||
|
||||
var music_player: AudioStreamPlayer
|
||||
var ui_click_player: AudioStreamPlayer
|
||||
|
||||
func _ready():
|
||||
music_player = AudioStreamPlayer.new()
|
||||
add_child(music_player)
|
||||
|
||||
ui_click_player = AudioStreamPlayer.new()
|
||||
ui_click_player.bus = "SFX"
|
||||
add_child(ui_click_player)
|
||||
|
||||
var orig_stream = _load_stream()
|
||||
if not orig_stream:
|
||||
push_error("Failed to load music stream: %s" % MUSIC_PATH)
|
||||
@@ -59,3 +65,9 @@ func _stop_music() -> void:
|
||||
if not music_player.playing:
|
||||
return
|
||||
music_player.stop()
|
||||
|
||||
func play_ui_click() -> void:
|
||||
var click_stream = load(UI_CLICK_SOUND_PATH)
|
||||
if click_stream and click_stream is AudioStream:
|
||||
ui_click_player.stream = click_stream
|
||||
ui_click_player.play()
|
||||
|
||||
Reference in New Issue
Block a user