Dialogues: animate text

This commit is contained in:
Alice Gaudon 2020-08-16 10:41:14 +02:00
parent 6f4c375465
commit d7c98374ba
5 changed files with 20 additions and 6 deletions

View File

@ -34,6 +34,8 @@ _global_script_class_icons={
config/name="Crabs Game" config/name="Crabs Game"
run/main_scene="res://scenes/startup.tscn" run/main_scene="res://scenes/startup.tscn"
boot_splash/image="res://images/titleCrab.png"
boot_splash/use_filter=false
config/icon="res://icon.png" config/icon="res://icon.png"
[display] [display]

View File

@ -10,13 +10,12 @@
[node name="Campfire (background)" type="AnimatedSprite" parent="."] [node name="Campfire (background)" type="AnimatedSprite" parent="."]
frames = ExtResource( 1 ) frames = ExtResource( 1 )
frame = 18
playing = true playing = true
centered = false centered = false
[node name="Ely" type="AnimatedSprite" parent="."] [node name="Ely" type="AnimatedSprite" parent="."]
frames = ExtResource( 2 ) frames = ExtResource( 2 )
frame = 97 frame = 63
playing = true playing = true
centered = false centered = false

View File

@ -24,7 +24,7 @@ script = ExtResource( 1 )
[node name="Fire" type="AnimatedSprite" parent="."] [node name="Fire" type="AnimatedSprite" parent="."]
frames = ExtResource( 6 ) frames = ExtResource( 6 )
animation = "start" animation = "start"
frame = 41 frame = 5
playing = true playing = true
centered = false centered = false
script = ExtResource( 1 ) script = ExtResource( 1 )

View File

@ -27,7 +27,10 @@ func start(dialogue : Array):
func _input(event): func _input(event):
if event.is_action_pressed("ui_accept"): if event.is_action_pressed("ui_accept"):
next() if text.visible_characters < text.text.length():
text.visible_characters = text.text.length()
else:
next()
func next() -> void: func next() -> void:
_index += 1 _index += 1
@ -38,6 +41,17 @@ func next() -> void:
_update() _update()
func _update() -> void: func _update() -> void:
text.text = _dialogue[_index].text
title.text = _dialogue[_index].name title.text = _dialogue[_index].name
text.text = _dialogue[_index].text
#expression = _dialogue[_index].expression #expression = _dialogue[_index].expression
animate_text()
func animate_text():
var animated = _index
text.visible_characters = 0
while animated == _index && text.visible_characters < text.text.length():
if text.text[text.visible_characters] == ' ':
text.visible_characters += 1
text.visible_characters += 1
yield(get_tree().create_timer(0.05), 'timeout')

View File

@ -25,7 +25,6 @@ func start_dialogue(dialog_path : String) -> DialogueAction:
dialogue.start() dialogue.start()
return dialogue return dialogue
var crab_finished = false var crab_finished = false
var crab_step = 0 var crab_step = 0
func do_crab_step(): func do_crab_step():