Browse Source

fix console errors

Arnaud Vergnet 2 years ago
parent
commit
3ba645b724

+ 4
- 3
mini-game/MiniGame.gd View File

@@ -64,14 +64,14 @@ func start():
64 64
 	BackgroundMusic.crossfade_to(MUSIC, -10, 1)
65 65
 	start_timer_UI.init()
66 66
 	var t = Timer.new()
67
-	t.set_wait_time(0.5)
67
+	t.wait_time = 0.5
68
+	t.autostart = true
68 69
 	add_child(t)
69
-	t.start()
70 70
 	for n in range(3,0,-1):
71 71
 		start_timer_UI.update_timer(n)
72 72
 		yield(t, "timeout")
73 73
 	start_timer_UI.update_timer(0)
74
-	instructionsUI._init()
74
+	instructionsUI.start()
75 75
 	foreground.start()
76 76
 	player.start()
77 77
 	yield(t, "timeout")
@@ -90,6 +90,7 @@ func start():
90 90
 
91 91
 func stop():
92 92
 	foreground.stop()
93
+	instructionsUI.stop()
93 94
 	player.stop()
94 95
 	spawner.stop()
95 96
 	score_timer.stop()

+ 25
- 19
mini-game/scenes/decor/instructionsUI.gd View File

@@ -1,32 +1,38 @@
1 1
 extends Control
2 2
 
3
+onready var timer := $Timer
4
+
3 5
 var jump_key = "dialogic_next"
4 6
 
5
-var jumped = false
7
+var waiting = false
6 8
 
7
-func _wait_for_jump():
8
-	var t = Timer.new()
9
-	t.set_wait_time(0.5)
10
-	add_child(t)
11
-	t.start()
12
-	while(!jumped):
13
-		yield(t, "timeout")
14
-		if visible:
15
-			hide()
16
-		else:
17
-			show()
18
-			yield(t, "timeout")
19
-	hide()
20 9
 
21 10
 func _input(event):
22
-	if event.is_action_pressed(jump_key):
23
-			jumped = true
11
+	if event.is_action_pressed(jump_key) and waiting:
12
+			waiting = false
13
+
24 14
 
25
-# Called when the node enters the scene tree for the first time.
26 15
 func _ready():
27 16
 	hide()
28 17
 
29 18
 
30
-func _init():
19
+func stop():
20
+	waiting = false
21
+	timer.stop()
22
+	hide()
23
+
24
+
25
+func start():
26
+	waiting = true
27
+	timer.start()
31 28
 	show()
32
-	_wait_for_jump()
29
+
30
+
31
+func _on_Timer_timeout() -> void:
32
+	if waiting:
33
+		if visible:
34
+			hide()
35
+		else:
36
+			show()
37
+	else:
38
+		stop()

+ 5
- 0
mini-game/scenes/decor/instructionsUI.tscn View File

@@ -36,3 +36,8 @@ margin_bottom = 207.0
36 36
 custom_fonts/font = SubResource( 1 )
37 37
 text = "Appuyer sur ESPACE pour sauter"
38 38
 align = 1
39
+
40
+[node name="Timer" type="Timer" parent="."]
41
+wait_time = 0.5
42
+
43
+[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]

+ 0
- 1
mini-game/scenes/spawner/spawner.gd View File

@@ -70,5 +70,4 @@ func start():
70 70
 func stop():
71 71
 	timer.stop()
72 72
 	for obj in items.get_children():
73
-		remove_child(obj)
74 73
 		obj.queue_free()

Loading…
Cancel
Save