Textboxes (upcoming v.0.2.0 update)
Originally I was manually creating all the textboxes (which was a pain), with the following script:
Click to expand code
extends CanvasLayer
@onready var text_displayed: RichTextLabel = $MarginContainer/Panel/MarginContainer/Panel/TextDisplayed
@onready var symbol: RichTextLabel = $MarginContainer/Panel/MarginContainer/Panel/Symbol
var visible_characters: int = 0
var last_sound_character: int = -1 # Track last character that triggered a sound
var text = [
“This is a textbox”,
“This is a continuation of said textbox”,
“This is the repeated dialogue”
]
func _ready() -> void:
Global.next_line = 0
text_displayed.text = text[Global.next_line] # Set initial text
text_displayed.visible_ratio = 0 # Start typewriter effect
func _physics_process(delta: float) -> void:
if Input.is_action_just_pressed(“dash”):
text_displayed.visible_ratio = 1 # Skip effect instantly
if text_displayed.visible_ratio < 1:
text_displayed.visible_ratio += 0.5 * delta # Typewriter effect speed
# Play sound effect for text animation
if text_displayed.visible_characters > last_sound_character:
AudioController.text_noise2()
last_sound_character = text_displayed.visible_characters # Update last played character
# Handle dialogue progression
if Input.is_action_just_pressed("ui_accept"):
text_displayed.visible = false # Hide text before updating
await get_tree().create_timer(0.1).timeout # Small delay to simulate closing
if Global.next_line < len(text) - 1:
Global.next_line += 1
else:
Global.next_line = 2 # Keep repeating last dialogue instead of going forward
text_displayed.text = text[Global.next_line] # Set new text
text_displayed.visible_ratio = 0 # Restart typewriter effect
last_sound_character = -1 # Reset sound tracking
text_displayed.visible = true # Show text again
Result:
This was SUPER inefficient however, so I decided to bite the bullet and install a Dialogue Manager.
I’ve begun using Dialogic (2) to handle all the textbox stuff, and I’ll probably continue using it for the rest of the project.
Result:
It handles a lot of the code for me (which is nice) and let’s me alternate between multiple different characters, expressions, and voices easily (solid 8.7/10).
- What?(now) -
My main focus is on finishing the town assets (backgrounds, buildings, interiors, npcs, etc.) and refining the player movement.
- Why? -
I can’t really begin level design till I have a movement system I’m comfortable with, so it’ll take some time before the game gets out of this “prototype” phase.
- When? -
Despite this, there should be an update to the game late March to mid April(???) that’ll feature a town/hub world and maybe 2 cutscenes?
That’s all for now.
Get Powder Trail
Powder Trail
A small retro platformer with RPG-esque storytelling.
More posts
- Web Version... Available?2 days ago
- V0.2.0 Release!9 days ago
Leave a comment
Log in with itch.io to leave a comment.