浏览代码

Add death sound when player dies

DricomDragon 5 年之前
父节点
当前提交
ed24a0986e
共有 2 个文件被更改,包括 7 次插入2 次删除
  1. 1 0
      Main.gd
  2. 6 2
      Main.tscn

+ 1 - 0
Main.gd

@@ -17,6 +17,7 @@ func game_over():
 	$MobTimer.stop()
 	$HUD.show_game_over()
 	$Music.stop()
+	$DeathSound.play()
 
 func _ready():
 	randomize() # Plant seed for random number generation

+ 6 - 2
Main.tscn

@@ -1,10 +1,11 @@
-[gd_scene load_steps=7 format=2]
+[gd_scene load_steps=8 format=2]
 
 [ext_resource path="res://Main.gd" type="Script" id=1]
 [ext_resource path="res://Enemy.tscn" type="PackedScene" id=2]
 [ext_resource path="res://Player.tscn" type="PackedScene" id=3]
 [ext_resource path="res://HUD.tscn" type="PackedScene" id=4]
 [ext_resource path="res://dodge_assets/art/House In a Forest Loop.ogg" type="AudioStream" id=5]
+[ext_resource path="res://dodge_assets/art/gameover.wav" type="AudioStream" id=6]
 
 [sub_resource type="Curve2D" id=1]
 _data = {
@@ -44,9 +45,12 @@ position = Vector2( 245.983, 380.055 )
 
 [node name="Music" type="AudioStreamPlayer" parent="."]
 stream = ExtResource( 5 )
+
+[node name="DeathSound" type="AudioStreamPlayer" parent="."]
+stream = ExtResource( 6 )
 [connection signal="timeout" from="MobTimer" to="." method="_on_MobTimer_timeout"]
 [connection signal="timeout" from="ScoreTimer" to="." method="_on_ScoreTimer_timeout"]
-[connection signal="timeout" from="StartTimer" to="." method="_on_StartTimer_timeout"]
 [connection signal="timeout" from="StartTimer" to="Player" method="spawn"]
+[connection signal="timeout" from="StartTimer" to="." method="_on_StartTimer_timeout"]
 [connection signal="hit" from="Player" to="." method="game_over"]
 [connection signal="start_game" from="HUD" to="." method="new_game"]