forked from ProfAndreaPollini/godot-rl-2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialogueLayer.gd
More file actions
36 lines (27 loc) · 804 Bytes
/
Copy pathDialogueLayer.gd
File metadata and controls
36 lines (27 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
extends CanvasLayer
var sentences = []
var current = 0
func _ready():
set_process_input(false)
func say(text):
sentences = text
current = 0
$MarginContainer/HBoxContainer/Label.text = sentences[0]
$MarginContainer/HBoxContainer/VBoxContainer/Label.text = str(current+1) + "/" + str(len(sentences))
$AnimationPlayer.play("show")
func next_page():
current += 1
if current >= len(sentences):
return false
else:
$MarginContainer/HBoxContainer/Label.text = sentences[current]
$MarginContainer/HBoxContainer/VBoxContainer/Label.text = str(current+1) + "/" + str(len(sentences))
return true
func _process(delta):
if Input.is_action_just_pressed("ui_accept"):
var ok = next_page()
if not ok:
hide()
func hide():
set_process_input(false)
$AnimationPlayer.play("hide")