0

我正在尝试制作约会模拟游戏,而我想做的一件事是在游戏中间单击鼠标,立即将字符串全部写入。

    extends RichTextLabel

var dialog = ["Hello There", "how are you"]
var page = 0


func _ready():

    set_bbcode(dialog[page])
    set_visible_characters(0)

func _input(event):
    if event is InputEventMouseButton:
        if get_visible_characters() > get_total_character_count():
            if page < dialog.size()-1:
                page += 1
                set_bbcode(dialog[page])
                set_visible_characters(0)

func _on_Timer_timeout():
    set_visible_characters(get_visible_characters() + 1)

为此,我想测量 bbcode 中的可见字符;但我只是不知道该怎么做。

4

1 回答 1

0

没关系,我想出了如何在这里做。

func _input(event):
if event is InputEventMouseButton:
    if get_visible_characters() > get_total_character_count():
        if page < dialog.size()-1:
            page += 1
            set_bbcode(dialog[page])
            set_visible_characters(0)
    if event is InputEventMouseButton:
        if get_visible_characters() < get_total_character_count():
            set_visible_characters(get_total_character_count())

只需将另一个事件类型输入放在已经存在的输入事件中,然后检查 get_visible_characters 是否小于 get_total_character_count。如果为真,则将可见字符设置为总字符数。

于 2018-10-20T18:10:22.223 回答