flappy-bird/UI.gd

33 lines
685 B
GDScript3
Raw Permalink Normal View History

2020-04-08 12:40:43 +02:00
extends CanvasLayer
var best = 0
var current = 0
var best_score;
var current_score;
var ready_text;
# Called when the node enters the scene tree for the first time.
func _ready():
best_score = get_node("MarginContainer/HBoxContainer/BestScore")
current_score = get_node("MarginContainer/HBoxContainer/CurrentScore")
ready_text = get_node("CenterContainer/ReadyText")
func _on_Player_start():
current = 0
ready_text.hide()
update_ui()
func _on_Player_hit():
ready_text.show()
best = max(best, current)
update_ui()
func _on_Player_passed():
current += 1
update_ui()
func update_ui():
best_score.text = "Best: "+str(best)
current_score.text = "Current: "+str(current)