diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-12-04 22:04:59 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-12-04 22:04:59 +0200 |
| commit | 872d1f9200584973b2156102f0e7f03b3d271687 (patch) | |
| tree | 0177cda13042d5e0b924d8dbe74f444a89034c27 /dialogue.gd | |
| parent | f97ee1d7c41e07296b6c31b9b85aa299805ba2f1 (diff) | |
Add initial dialogue system
Diffstat (limited to 'dialogue.gd')
| -rw-r--r-- | dialogue.gd | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/dialogue.gd b/dialogue.gd new file mode 100644 index 0000000..f085ed8 --- /dev/null +++ b/dialogue.gd @@ -0,0 +1,24 @@ +class_name Dialogue +extends Node + +signal next + +@onready var parent: Node2D = get_parent() +@onready var cam: GameCamera = parent.get_node("GameCamera") + +func say(who: Object, text: String): + var tb: TextBubble = preload("res://text_bubble.tscn").instantiate() + tb.text = text + if who is Node2D: + tb.global_position = who.global_position + Vector2(0, -20) + else: + tb.global_position = cam.global_position + + tb.add_to_group("text_bubbles") + parent.add_child(tb) + await next + +func _process(_delta: float): + if Input.is_action_just_pressed("action") or Input.is_action_just_pressed("jump"): + get_tree().call_group("text_bubbles", "queue_free") + next.emit() |
