Parcourir la source

Add main music

DricomDragon il y a 5 ans
Parent
commit
11db14b3ad
2 fichiers modifiés avec 8 ajouts et 2 suppressions
  1. 2 0
      Main.gd
  2. 6 2
      Main.tscn

+ 2 - 0
Main.gd

@@ -10,11 +10,13 @@ func new_game():
 	$StartTimer.start()
 	$HUD.update_score(score)
 	$HUD.show_message("Get ready")
+	$Music.play()
 
 func game_over():
 	$ScoreTimer.stop()
 	$MobTimer.stop()
 	$HUD.show_game_over()
+	$Music.stop()
 
 func _ready():
 	randomize() # Plant seed for random number generation

+ 6 - 2
Main.tscn

@@ -1,9 +1,10 @@
-[gd_scene load_steps=6 format=2]
+[gd_scene load_steps=7 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]
 
 [sub_resource type="Curve2D" id=1]
 _data = {
@@ -40,9 +41,12 @@ rotation = -6.07153e-08
 position = Vector2( 245.983, 380.055 )
 
 [node name="HUD" parent="." instance=ExtResource( 4 )]
+
+[node name="Music" type="AudioStreamPlayer" parent="."]
+stream = ExtResource( 5 )
 [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="Player" method="spawn"]
 [connection signal="timeout" from="StartTimer" to="." method="_on_StartTimer_timeout"]
+[connection signal="timeout" from="StartTimer" to="Player" method="spawn"]
 [connection signal="hit" from="Player" to="." method="game_over"]
 [connection signal="start_game" from="HUD" to="." method="new_game"]