Skip to content

Commit

Permalink
Fix ceiling trap sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
jakerosado committed Dec 2, 2023
1 parent dc875e1 commit b26fd92
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 11 additions & 1 deletion knytt/objects/bank6/TrapCeiling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ public override void _PhysicsProcess(float delta)
private void _on_Checker_body_entered(object body, bool up)
{
moving_up = up;
GetNode<AudioStreamPlayer2D>("HitSound2D").Play();

if (moving_up)
{
GetNode<AudioStreamPlayer2D>("MovingDown2D").Stop();
GetNode<AudioStreamPlayer2D>("MovingUp2D").Play();
}
else
{
GetNode<AudioStreamPlayer2D>("MovingUp2D").Stop();
GetNode<AudioStreamPlayer2D>("MovingDown2D").Play();
}
}
}
12 changes: 8 additions & 4 deletions knytt/objects/bank6/TrapCeiling.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=9 format=2]

[ext_resource path="res://knytt/objects/bank6/img/trap_ceiling.png" type="Texture" id=1]
[ext_resource path="res://knytt/objects/bank6/TrapCeiling.cs" type="Script" id=2]
[ext_resource path="res://knytt/SFXAudioPlayer2D.tscn" type="PackedScene" id=3]
[ext_resource path="res://knytt/data/Sfx/Roller Shot Hit.wav" type="AudioStream" id=4]

[ext_resource path="res://knytt/data/Sfx/Machine Turn B.wav" type="AudioStream" id=4]
[ext_resource path="res://knytt/data/Sfx/Machine Turn A.wav" type="AudioStream" id=5]

[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 45.8827, 9.66304 )
Expand Down Expand Up @@ -45,10 +45,14 @@ collision_mask = 3072
position = Vector2( 48, 3 )
shape = SubResource( 3 )

[node name="HitSound2D" parent="." instance=ExtResource( 3 )]
[node name="MovingDown2D" parent="." instance=ExtResource( 3 )]
stream = ExtResource( 4 )
volume_db = 2.5

[node name="MovingUp2D" parent="." instance=ExtResource( 3 )]
stream = ExtResource( 5 )
volume_db = 2.5

[connection signal="body_entered" from="Area2D" to="." method="onDeadlyAreaEntered"]
[connection signal="body_entered" from="DownChecker" to="." method="_on_Checker_body_entered" binds= [ true ]]
[connection signal="body_entered" from="UpChecker" to="." method="_on_Checker_body_entered" binds= [ false ]]

1 comment on commit b26fd92

@jakerosado
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolves: youkaicountry#198

Please sign in to comment.