diff --git a/NumpadButton.tscn b/NumpadButton.tscn index cee9f8f..d8de7f4 100644 --- a/NumpadButton.tscn +++ b/NumpadButton.tscn @@ -1,11 +1,17 @@ -[gd_scene load_steps=2 format=3 uid="uid://d0iltvfnuao1q"] +[gd_scene load_steps=3 format=3 uid="uid://d0iltvfnuao1q"] [ext_resource type="Script" uid="uid://cj0cg8u5mclxe" path="res://numpad_button.gd" id="1_orrea"] +[ext_resource type="AudioStream" uid="uid://ctkxotof2clun" path="res://assets/numpad/audio/click.wav" id="2_hixh2"] -[node name="TextureButton" type="TextureButton"] +[node name="TextureButton" type="TextureButton" node_paths=PackedStringArray("audio_player")] script = ExtResource("1_orrea") +audio_player = NodePath("AudioStreamPlayer2D") [node name="Sprite2D" type="Sprite2D" parent="."] region_enabled = true +[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("2_hixh2") +volume_db = 2.385 + [connection signal="button_down" from="." to="." method="_on_button_down"] diff --git a/assets/numpad/audio/click.wav b/assets/numpad/audio/click.wav new file mode 100644 index 0000000..5dc9a8a Binary files /dev/null and b/assets/numpad/audio/click.wav differ diff --git a/assets/numpad/audio/click.wav.import b/assets/numpad/audio/click.wav.import new file mode 100644 index 0000000..bea2024 --- /dev/null +++ b/assets/numpad/audio/click.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://ctkxotof2clun" +path="res://.godot/imported/click.wav-4383acbd80dcc81771c497565ff896f2.sample" + +[deps] + +source_file="res://assets/numpad/audio/click.wav" +dest_files=["res://.godot/imported/click.wav-4383acbd80dcc81771c497565ff896f2.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/numpad_button.gd b/numpad_button.gd index a63ceb7..6ab0bad 100644 --- a/numpad_button.gd +++ b/numpad_button.gd @@ -3,6 +3,7 @@ extends TextureButton @export var button_value = 0 @export var button_texture: Texture2D @export var button_region: Rect2 +@export var audio_player: AudioStreamPlayer2D @onready var parent: Numpad = get_parent() @@ -12,6 +13,8 @@ func _ready() -> void: func _on_button_down() -> void: + audio_player.play() + if button_value <= 9: parent.keypad_entry(button_value) elif button_value == 10: