Flopsy/objects/speech_bubble/speech_bubble.gd

37 lines
689 B
GDScript3
Raw Normal View History

2022-07-17 14:24:15 +02:00
extends ReferenceRect
export var speed : float = 0.05
export var flip_h : bool
export var pitch : float = 1
signal animation_ready
func _ready():
modulate.a = 0
if flip_h:
$Arrow.flip_h = true
$Arrow.set_position(Vector2(0, rect_size.y))
$TypeSound.pitch_scale = pitch
func say(text : String):
2022-07-18 20:36:48 +02:00
var tree = get_tree()
2022-07-17 14:24:15 +02:00
$Label.visible_characters = 0
$Label.text = text
if modulate.a != 1:
$Animation.play("fade")
for i in text.length() + 1:
$Label.visible_characters = i
$TypeSound.play()
2022-07-18 20:36:48 +02:00
if tree != null:
yield(tree.create_timer(speed), "timeout")
2022-07-17 14:24:15 +02:00
emit_signal("animation_ready")
func fade_out():
if modulate.a != 0:
$Animation.play_backwards("fade")