Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Lynn_Len |
I’m using a timer node to write out the individual characters one at a time every time the timer would emit the timeout signal; but when a page of dialogue was done writing and would go on to the next page of dialogue i would start where the previous page left off.
extends Panel
onready var text_node = $Label
onready var sprite_node = $Sprite
onready var dialogue_node = $RichTextLabel
onready var rect_node = $TextureRect
onready var audio_node = $AudioStreamPlayer2D
onready var timer_node = $Timer
var dialogue_list = []
var is_Done = false
func _ready():
pass
func add_dialogue(args):
dialogue_list.push_back(args)
func update_dialogue():
if dialogue_list.size() > 0:
var new_bg = load(dialogue_list[0][0])
rect_node.set_texture(new_bg)
var new_texture = load(dialogue_list[0][1])
sprite_node.set_texture(new_texture)
dialogue_node.set_bbcode(dialogue_list[0][2])
text_node.set_text(dialogue_list[0][3])
audio_node.stream = load(dialogue_list[0][4])
audio_node.play()
dialogue_list.pop_front()
func _input(event):
if event is InputEventMouseButton and event.is_pressed():
match event.button_index:
BUTTON_LEFT:
if is_Done:
update_dialogue()
is_Done = false
else:
dialogue_node.visible_characters = dialogue_node.get_total_character_count()
is_Done = true
func _on_Timer_timeout():
if dialogue_node.visible_characters < dialogue_node.get_total_character_count():
dialogue_node.visible_characters += 1
if dialogue_node.visible_characters == dialogue_node.get_total_character_count():
is_Done = true
pass
extends Node
onready var dialogue_system = get_node("/root/Node/Panel")
func _ready():
dialogue_system.add_dialogue(["res://Sprite/1024700-spiritedawaybackgroundart-04.jpg","res://icon.png", "hello goodbye, hello goodbye, now say goodbye i say hello", "lu", "res://Music/Test_Song.wav"])
dialogue_system.add_dialogue(["res://Sprite/1024700-spiritedawaybackgroundart-04.jpg","res://icon.png", "what do you think of the song, was it great? was it fantastic?", "lu", "res://Music/Test_Song.wav"])
Can someone tell how do i fix this please.
Could you please provide the error output you get? Showing us your node hierarchy would also definitely help us help you.
Thanks!
ResExsention | 2019-03-19 02:09