extends Node2D

signal completed()

export (int) var delay = 3
var timer
var time_left = delay


func _ready():
	# Set up a timer
	timer = Timer.new()
	add_child(timer)
	timer.wait_time = 1.0
	timer.connect("timeout", self, "_timeout")
	


func start():
	set_visible(true)
	time_left = delay
	$Number.set_text("%d" % time_left)
	timer.start()
	return self
	
func _timeout():
	#print("Timeout !")
	time_left -= 1
	if time_left < 0:
		timer.stop()
		set_visible(false)
	elif time_left == 0:
		# Go !
		$Number.set_text("GO")
		emit_signal("completed")
	else:
		$Number.set_text("%d" % time_left)
		