From 3ba645b724d683d6023864d2d1b3abb2e803553d Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Thu, 6 May 2021 11:53:51 +0200 Subject: [PATCH] fix console errors --- mini-game/MiniGame.gd | 7 ++-- mini-game/scenes/decor/instructionsUI.gd | 44 ++++++++++++---------- mini-game/scenes/decor/instructionsUI.tscn | 5 +++ mini-game/scenes/spawner/spawner.gd | 1 - 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/mini-game/MiniGame.gd b/mini-game/MiniGame.gd index f49cf9e..0fb5c9f 100644 --- a/mini-game/MiniGame.gd +++ b/mini-game/MiniGame.gd @@ -64,14 +64,14 @@ func start(): BackgroundMusic.crossfade_to(MUSIC, -10, 1) start_timer_UI.init() var t = Timer.new() - t.set_wait_time(0.5) + t.wait_time = 0.5 + t.autostart = true add_child(t) - t.start() for n in range(3,0,-1): start_timer_UI.update_timer(n) yield(t, "timeout") start_timer_UI.update_timer(0) - instructionsUI._init() + instructionsUI.start() foreground.start() player.start() yield(t, "timeout") @@ -90,6 +90,7 @@ func start(): func stop(): foreground.stop() + instructionsUI.stop() player.stop() spawner.stop() score_timer.stop() diff --git a/mini-game/scenes/decor/instructionsUI.gd b/mini-game/scenes/decor/instructionsUI.gd index ba301b2..3fb995f 100644 --- a/mini-game/scenes/decor/instructionsUI.gd +++ b/mini-game/scenes/decor/instructionsUI.gd @@ -1,32 +1,38 @@ extends Control +onready var timer := $Timer + var jump_key = "dialogic_next" -var jumped = false +var waiting = false -func _wait_for_jump(): - var t = Timer.new() - t.set_wait_time(0.5) - add_child(t) - t.start() - while(!jumped): - yield(t, "timeout") - if visible: - hide() - else: - show() - yield(t, "timeout") - hide() func _input(event): - if event.is_action_pressed(jump_key): - jumped = true + if event.is_action_pressed(jump_key) and waiting: + waiting = false + -# Called when the node enters the scene tree for the first time. func _ready(): hide() -func _init(): +func stop(): + waiting = false + timer.stop() + hide() + + +func start(): + waiting = true + timer.start() show() - _wait_for_jump() + + +func _on_Timer_timeout() -> void: + if waiting: + if visible: + hide() + else: + show() + else: + stop() diff --git a/mini-game/scenes/decor/instructionsUI.tscn b/mini-game/scenes/decor/instructionsUI.tscn index a3e6125..7b0fad5 100644 --- a/mini-game/scenes/decor/instructionsUI.tscn +++ b/mini-game/scenes/decor/instructionsUI.tscn @@ -36,3 +36,8 @@ margin_bottom = 207.0 custom_fonts/font = SubResource( 1 ) text = "Appuyer sur ESPACE pour sauter" align = 1 + +[node name="Timer" type="Timer" parent="."] +wait_time = 0.5 + +[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] diff --git a/mini-game/scenes/spawner/spawner.gd b/mini-game/scenes/spawner/spawner.gd index 9b29f51..1fb5109 100644 --- a/mini-game/scenes/spawner/spawner.gd +++ b/mini-game/scenes/spawner/spawner.gd @@ -70,5 +70,4 @@ func start(): func stop(): timer.stop() for obj in items.get_children(): - remove_child(obj) obj.queue_free()