Flopsy/scenes/hud/hud.gd

34 lines
1.1 KiB
GDScript3
Raw Permalink Normal View History

2022-07-17 14:24:15 +02:00
extends CanvasLayer
export var font_color : Color = Color(0, 0, 0)
# Called when the node enters the scene tree for the first time.
func _ready():
2022-07-17 17:08:39 +02:00
set_font_color(font_color)
2022-07-18 12:58:38 +02:00
func _process(delta):
$HUD_Items/ScoreLabel.text = str(GlobalState.coins)
$HUD_Items/PlayerItems/Key_Yellow.visible = GlobalState.keys['yellow']
2022-07-18 17:00:53 +02:00
$HUD_Items/PlayerItems/Key_Green.visible = GlobalState.keys['green']
$HUD_Items/PlayerItems/Key_Red.visible = GlobalState.keys['red']
$HUD_Items/PlayerItems/Key_Blue.visible = GlobalState.keys['blue']
$HUD_Items/PlayerItems/health99.visible = GlobalState.health > 66
$HUD_Items/PlayerItems/health66.visible = GlobalState.health > 33
$HUD_Items/PlayerItems/health33.visible = GlobalState.health > 0
2022-07-18 12:58:38 +02:00
2022-07-17 17:08:39 +02:00
func set_font_color(color: Color):
font_color = color
2022-07-17 14:24:15 +02:00
$HUD_Items/ScoreLabel.add_color_override("font_color", font_color)
func scene_fadeout():
$SceneTransition/Animation.play_backwards("Fade")
yield($SceneTransition/Animation, "animation_finished")
func hud_visible(value: bool):
$HUD_Items.visible = value
func scene_fadein():
$SceneTransition/Animation.play("Fade")
yield($SceneTransition/Animation, "animation_finished")