From db8578224cd75de76a6e3de63c17716ba83b3b0e Mon Sep 17 00:00:00 2001 From: myin Date: Sat, 23 Sep 2023 15:35:21 +0200 Subject: [PATCH] add debounce audio --- godot/shared/DebounceAudio.gd | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 godot/shared/DebounceAudio.gd diff --git a/godot/shared/DebounceAudio.gd b/godot/shared/DebounceAudio.gd new file mode 100644 index 0000000..c789460 --- /dev/null +++ b/godot/shared/DebounceAudio.gd @@ -0,0 +1,12 @@ +extends AudioStreamPlayer + +var timer: Timer + +func _ready(): + timer = Timer.new() + timer.one_shot = true + add_child(timer) + timer.timeout.connect(func(): super.play()) + +func play_debounce(time := 0.1): + timer.start(time)