diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-11-18 02:11:52 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-11-18 02:11:52 +0100 |
| commit | 95f0826c2c168b34d41c8d1eed853ce4c9dc018c (patch) | |
| tree | 2e9cd4e7e997782c6e1a588c3fc764aa624feed2 | |
| parent | 41be616f2dd56bdc58df50f568c6efbf944742eb (diff) | |
| download | nj26-95f0826c2c168b34d41c8d1eed853ce4c9dc018c.tar.gz | |
Set countdown.tscn as child of Spatial.tscn
| -rw-r--r-- | Spatial.gd | 5 | ||||
| -rw-r--r-- | Spatial.tscn | 5 | ||||
| -rw-r--r-- | countdown.gd | 5 | ||||
| -rw-r--r-- | countdown.tscn | 2 |
4 files changed, 10 insertions, 7 deletions
@@ -6,7 +6,6 @@ var zombie_scene = preload("res://zombie.tscn") var pwup = preload("res://powerup.tscn") var pw = preload("res://powerup.gd") var gameover = preload("res://game-over.tscn").instance() -var countdown = preload("res://countdown.tscn").instance() var green_points = 0 var pink_points = 0 @@ -182,7 +181,6 @@ func start_game(): for z in zombies: z.set_can_move(true) - get_tree().root.remove_child(countdown) $game_time.start(120) func go_back(): @@ -216,7 +214,6 @@ func _ready(): $game_time.start(120) $game_time.stop() __ = $game_time.connect("timeout", self, "game_over") - get_tree().root.add_child(countdown) - __ = countdown.connect("timeout", self, "start_game") + __ = $countdown.connect("timeout", self, "start_game") __ = connect("new_points", self, "on_points") __ = gameover.connect("go_back", self, "go_back") diff --git a/Spatial.tscn b/Spatial.tscn index af9c626..f7d86ec 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=26 format=2] +[gd_scene load_steps=27 format=2] [ext_resource path="res://floor.png" type="Texture" id=1] [ext_resource path="res://sky.tscn" type="PackedScene" id=2] @@ -7,6 +7,7 @@ [ext_resource path="res://basefloor.gd" type="Script" id=5] [ext_resource path="res://vera/Vera.ttf" type="DynamicFontData" id=6] [ext_resource path="res://vera/VeraBd.ttf" type="DynamicFontData" id=7] +[ext_resource path="res://countdown.tscn" type="PackedScene" id=8] [ext_resource path="res://sfx/p0/Power Up.wav" type="AudioStream" id=9] [ext_resource path="res://sfx/p1/Power Up.wav" type="AudioStream" id=10] [ext_resource path="res://sfx/p2/Power Up.wav" type="AudioStream" id=11] @@ -259,3 +260,5 @@ stream = ExtResource( 11 ) [node name="p3" type="AudioStreamPlayer" parent="powerup"] stream = ExtResource( 12 ) + +[node name="countdown" parent="." instance=ExtResource( 8 )] diff --git a/countdown.gd b/countdown.gd index 7788576..b18c3d8 100644 --- a/countdown.gd +++ b/countdown.gd @@ -3,11 +3,12 @@ extends Node2D signal timeout func _process(_delta): - if $Timer.time_left < 1: + if $Timer.time_left < 1 and not $Timer.is_stopped(): emit_signal("timeout") + $CanvasLayer/CenterContainer/countdown.visible = false $CanvasLayer/CenterContainer/countdown.text = "%d" % $Timer.time_left # Called when the node enters the scene tree for the first time. func _ready(): - $Timer.start(5) + $Timer.start() diff --git a/countdown.tscn b/countdown.tscn index c5fa7af..cfa3162 100644 --- a/countdown.tscn +++ b/countdown.tscn @@ -32,3 +32,5 @@ custom_fonts/font = SubResource( 1 ) text = "3" [node name="Timer" type="Timer" parent="."] +wait_time = 5.0 +one_shot = true |
