# Duane's Dungeon - a rogue-like game # Copyright (C) 2023 Duane Robertson # vanishing_label.gd - a label that fades away # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . extends Label class_name VanishingLabel # a label that fades away and dies var lifetime:float var text_size:int var tween:Tween func _init(txt:String, col:=Color.WHITE, tim:=4, \ sz:=40, al:=HORIZONTAL_ALIGNMENT_CENTER): text = txt lifetime = tim modulate = col text_size = sz horizontal_alignment = al func _ready(): label_settings = LabelSettings.new() label_settings.font_size = text_size label_settings.outline_color = Color.BLACK label_settings.outline_size = 10 # label_settings.line_spacing = 0 add_theme_font_override('font_size', G.font) tween = get_tree().create_tween() tween.tween_property(self, 'modulate:a', 0.1, lifetime).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_CUBIC) tween.tween_callback(self.queue_free) #.set_delay(0.1) func _exit_tree(): tween.kill()