Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Alexander (notraffic |
I want to play a sound after clicking on a RichTextLabel which shows the next dialog. All what I got is:
extends RichTextLabel
var dialog = ["Welcome to the game!", "Test"]
var page = 0
func _ready():
set_bbcode(dialog[page])
set_visible_characters(0)
set_process_input(true)
func _input(event):
if event.type == InputEvent.MOUSE_BUTTON && event.is_pressed():
if get_visible_characters() > get_total_character_count():
if page < dialog.size()-1:
page += 1
set_bbcode(dialog[page])
set_visible_characters(0)
get_tree().get_root().get_node("Control").get_node("SamplePlayer").play("Typing")
if dialog.size() == get_total_character_count():
get_tree().get_root().get_node("Control").get_node("SamplePlayer").stop_all()
func _on_Timer_timeout():
set_visible_characters(get_visible_characters()+1)
The line which doesn’t work is line 22:
get_tree().get_root().get_node(“Control”).get_node(“SamplePlayer”).stop_all()
Instead of playing, the sound doesn’t play at all. Can anyone help me?