123456789101112131415161718192021222324252627282930313233343536 |
- extends LabelWithFont
- class_name WarningSign
- var n
- var DURATION = 3
- const V_OFFSET = 40
- func _init(_text, duration):
- font_path = "res://fonts/Now FL/Now-SemiBold.otf"
- font_size = 30
- modulate = Color8(255,0,255)
- text = _text
- DURATION = duration
- func _ready():
- var timer = Timer.new()
- timer.wait_time = DURATION
- timer.connect("timeout",self,'on_timeout')
- add_child(timer)
- timer.start()
- n = Node2D.new()
- n.z_index = 6
- n.z_as_relative = false
- get_parent().add_child(n)
- get_parent().remove_child(self)
- n.add_child(self)
- rect_position = Vector2(get_viewport().size.x/2.0 - rect_size.x/2.0, V_OFFSET)
- func on_timeout():
- self_destruct()
- func self_destruct():
- n.queue_free()
|