20 lines
477 B
GDScript3
20 lines
477 B
GDScript3
|
extends CanvasLayer
|
||
|
|
||
|
@onready var label = $Sprite2D/RichTextLabel
|
||
|
signal Done
|
||
|
|
||
|
func typewrite(text,sound,speed, hide_after):
|
||
|
visible = true
|
||
|
label.text = text
|
||
|
label.visible_characters = 0
|
||
|
$AudioStreamPlayer.stream = sound
|
||
|
var wait_time = speed / len(text)
|
||
|
for i in range(len(text)+1):
|
||
|
label.visible_characters = i
|
||
|
$AudioStreamPlayer.play()
|
||
|
await get_tree().create_timer(wait_time).timeout
|
||
|
await get_parent().interact
|
||
|
if hide_after:
|
||
|
visible = false
|
||
|
Done.emit()
|