Launcher/Notice_msg.gd

32 lines
816 B
GDScript3
Raw Permalink Normal View History

2022-10-28 15:16:00 -05:00
extends Node2D
2022-10-28 15:44:43 -05:00
# Define variables (These will be overriden by another script)
2022-10-28 15:16:00 -05:00
var message
var type
2022-10-28 15:44:43 -05:00
# When everything is loaded,
2022-10-28 15:16:00 -05:00
func _ready():
2022-10-28 15:44:43 -05:00
# If the type is "warning",
2022-10-28 15:16:00 -05:00
if type == "warning":
2022-10-28 15:44:43 -05:00
# Add a yellow color override
2022-10-28 15:16:00 -05:00
$Label.add_color_override("font_color", Color(255, 69, 0))
2022-10-28 15:44:43 -05:00
# If the type is "alert",
2022-10-28 15:16:00 -05:00
if type == "alert":
2022-10-28 15:44:43 -05:00
# Add a red color override
2022-10-28 15:16:00 -05:00
$Label.add_color_override("font_color", Color(255, 0, 0))
2022-10-28 15:44:43 -05:00
# Every process tick
func _process(_delta):
2022-10-28 15:44:43 -05:00
# Set the Label's text to the given message
2022-10-28 15:16:00 -05:00
$Label.text = message
2022-10-28 15:44:43 -05:00
# When the TTL timer time's out,
2022-10-28 15:16:00 -05:00
func _on_TTL_timeout():
2022-10-28 15:44:43 -05:00
# Start the move_off_screen animation
2022-10-28 15:16:00 -05:00
$AnimationPlayer.play("move_off_screen")
2022-10-28 15:44:43 -05:00
# When animation finishes,
func _on_AnimationPlayer_animation_finished(_anim_name):
2022-10-28 15:44:43 -05:00
# Queue_free (AKA, delete) this node
2022-10-28 15:16:00 -05:00
queue_free()