Added button sound

This commit is contained in:
alex-kumpula 2023-11-12 15:07:40 -07:00
parent 13e856791b
commit db83354c6a
7 changed files with 65 additions and 7 deletions

View File

@ -10,10 +10,19 @@ public partial class AdvanceButton : Button
public override void _Ready()
{
TAS = GetNode<TAS_System>("/root/TAS_System");
this.Pressed += () => { TAS.Advance(1); };
AudioStreamPlayer buttonSound = this.GetNode<AudioStreamPlayer>("../../ButtonSound");
bool playSound = true;
this.Pressed += () => {
TAS.Advance(1);
if (playSound) buttonSound.Play();
playSound = false;
};
this.ButtonDown += () => { this.isButtonPressed = true; };
this.ButtonUp += () => { this.isButtonPressed = false; TAS.ResetSpeedup(); };
this.ButtonUp += () => { this.isButtonPressed = false; TAS.ResetSpeedup(); playSound = true; };
}
// Called every frame. 'delta' is the elapsed time since the previous frame.

View File

@ -10,12 +10,18 @@ public partial class RegressButton : Button
public override void _Ready()
{
TAS = GetNode<TAS_System>("/root/TAS_System");
AudioStreamPlayer buttonSound = this.GetNode<AudioStreamPlayer>("../../ButtonSound");
bool playSound = true;
this.Pressed += () => {
TAS.Regress(1);
if (playSound) buttonSound.Play();
playSound = false;
};
this.ButtonDown += () => { this.isButtonPressed = true; TAS.StopIncrementingFrames(); };
this.ButtonUp += () => { this.isButtonPressed = false; TAS.ResetSpeedup(); };
this.ButtonUp += () => { this.isButtonPressed = false; TAS.ResetSpeedup(); playSound = true; };
}
public virtual void OnFrameIncremented(int newFrame)

View File

@ -1,10 +1,12 @@
[gd_scene load_steps=9 format=3 uid="uid://b1uf31ed6h0ir"]
[gd_scene load_steps=11 format=3 uid="uid://b1uf31ed6h0ir"]
[ext_resource type="Script" path="res://UI/TAS UI/CurrentFrameLabel.cs" id="1_27u4w"]
[ext_resource type="Script" path="res://UI/TAS UI/TAS UI.gd" id="1_ytl0x"]
[ext_resource type="Script" path="res://UI/TAS UI/RegressButton.cs" id="2_fhmsa"]
[ext_resource type="AudioStream" uid="uid://cio6yfcnyf2lx" path="res://audio/note.wav" id="2_nsxig"]
[ext_resource type="Script" path="res://UI/TAS UI/Label2.gd" id="2_otida"]
[ext_resource type="Script" path="res://UI/TAS UI/AdvanceButton.cs" id="3_0ti6q"]
[ext_resource type="Script" path="res://UI/TAS UI/UIAudioPlayer.cs" id="3_251uv"]
[ext_resource type="Script" path="res://UI/TAS UI/StopIncrementButton.cs" id="4_4gd4c"]
[ext_resource type="Script" path="res://UI/TAS UI/StartIncrementButton.cs" id="5_5af83"]
[ext_resource type="Script" path="res://UI/TAS UI/ResetFramesButton.cs" id="6_nwwkv"]
@ -19,6 +21,10 @@ grow_vertical = 2
mouse_filter = 2
script = ExtResource("1_ytl0x")
[node name="ButtonSound" type="AudioStreamPlayer" parent="."]
stream = ExtResource("2_nsxig")
script = ExtResource("3_251uv")
[node name="DEBUG" type="Control" parent="."]
visible = false
layout_mode = 1

View File

@ -0,0 +1,15 @@
using Godot;
using System;
public partial class UIAudioPlayer : AudioStreamPlayer
{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
}

BIN
godot/audio/note.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cio6yfcnyf2lx"
path="res://.godot/imported/note.wav-f74766d8f2fafbaa9729bf4b58d8f300.sample"
[deps]
source_file="res://audio/note.wav"
dest_files=["res://.godot/imported/note.wav-f74766d8f2fafbaa9729bf4b58d8f300.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=0

View File

@ -28,7 +28,6 @@ camera = NodePath("Camera3D")
initial_target = NodePath("../grape")
[node name="Camera3D" type="Camera3D" parent="controller" index="1"]
current = true
[node name="billiard" parent="." index="4" instance=ExtResource("3_kg8e8")]
@ -50,5 +49,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0205169, 0.381115, -0.02601
transform = Transform3D(0.358936, -0.000516907, -0.141382, 0.000873357, 0.385775, 0.00080681, 0.14138, -0.00107074, 0.358935, -1.91181, 1.97725, -0.189681)
[node name="Domino" parent="." index="11" instance=ExtResource("8_2krw6")]
transform = Transform3D(0.999994, -0.00349065, 0, -1.52581e-10, -4.37111e-08, 1, -0.00349065, -0.999994, -4.37114e-08, 0.087864, 0.212463, -1.74624)
continuous_cd = false
transform = Transform3D(0.999994, -0.00349065, 0, -1.52581e-10, -4.37111e-08, 1, -0.00349065, -0.999994, -4.37114e-08, 0.087864, 1.44443, -0.526911)