putting together in Main scene
This commit is contained in:
32
Countdown.gd
Normal file
32
Countdown.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
extends Node2D
|
||||
|
||||
signal race_started
|
||||
|
||||
export (int) var delay = 3
|
||||
var timer
|
||||
|
||||
|
||||
func _ready():
|
||||
# Set up a timer
|
||||
timer = Timer.new()
|
||||
add_child(timer)
|
||||
timer.wait_time = 1.0
|
||||
timer.connect("timeout", self, "_timeout")
|
||||
timer.start()
|
||||
|
||||
$Number.set_text("%d" % delay)
|
||||
|
||||
|
||||
func _timeout():
|
||||
#print("Timeout !")
|
||||
delay -= 1
|
||||
if delay < 0:
|
||||
timer.stop()
|
||||
set_visible(false)
|
||||
elif delay == 0:
|
||||
# Go !
|
||||
$Number.set_text("GO")
|
||||
emit_signal("race_started")
|
||||
else:
|
||||
$Number.set_text("%d" % delay)
|
||||
|
||||
Reference in New Issue
Block a user