Godot 模拟rpg对话框并根据内容长短动态调整加载时间
作者:
Hi小胡 | 来源:发表于
2020-05-26 15:53 被阅读0次
scene:
script:
extends Control
var txt
func _on_Button_pressed():
showText()
pass
func showText():
# txt = "哈哈哈哈哈哈哈哈哈哈哈哈" # 短字符串
txt = "尽管角色扮演游戏的形式多样,例如某些交换卡片游戏、战争游戏甚至动作游戏都可能含有角色扮演元素,包括人物升级、故事推进,但分类时却不包括在角色扮演游戏之内。" # 长字符串
var speed = 0.02 # 单个字符显示所需时间
var time = speed * txt.length() # 根据字数动态调整动画时间
$dialogbox/RichTextLabel.bbcode_text = txt
$dialogbox/RichTextLabel.percent_visible = 0
$dialogbox/Tween.interpolate_property($dialogbox/RichTextLabel,"percent_visible",0,1,time,Tween.TRANS_LINEAR,Tween.EASE_IN_OUT)
$dialogbox/Tween.start()
pass
本文标题:Godot 模拟rpg对话框并根据内容长短动态调整加载时间
本文链接:https://www.haomeiwen.com/subject/mvkvahtx.html
网友评论