26 lines
713 B
GDScript
26 lines
713 B
GDScript
extends Node
|
|
|
|
@export var dialogContainer: MarginContainer
|
|
@export var dialogTextLabel: RichTextLabel
|
|
|
|
func set_dialog(text: String, seconds: float = 1) -> void:
|
|
dialogTextLabel.text = text
|
|
dialogTextLabel.visible_ratio = 0
|
|
var ratio: float = 0
|
|
|
|
if text.length() == 0:
|
|
dialogContainer.visible = false
|
|
return
|
|
else:
|
|
dialogContainer.visible = true
|
|
|
|
var increment: float = (1 / seconds)/ 60.0
|
|
|
|
while true:
|
|
#don't interfere with other timers
|
|
if dialogTextLabel.visible_ratio < ratio or dialogTextLabel.visible_ratio >= 1:
|
|
return
|
|
dialogTextLabel.visible_ratio += increment
|
|
ratio = dialogTextLabel.visible_ratio
|
|
await get_tree().create_timer(1.0/60.0).timeout #update proportional to 60 FPS
|