This translation is community contributed and may not be up to date. We only maintain the English version of the documentation. Read this manual in English
Defold支持一种特定类型的GUI节点,允许在GUI场景中渲染文本。项目中添加的任何字体资源都可以用于文本节点渲染。
您希望在GUI文本节点中使用的字体必须添加到GUI组件中。可以右键单击Fonts文件夹,使用GUI顶部菜单或按相应的键盘快捷键。
文本节点具有一组特殊属性:
通过设置节点 pivot,您可以更改文本的对齐模式。
Center
、North
或South
,则文本居中对齐。West
模式,则文本左对齐。East
模式,则文本右对齐。文本节点响应任何通用的节点操作函数,用于设置大小、pivot、颜色等。存在一些仅用于文本节点的函数:
gui.set_font()
函数。gui.set_line_break()
函数。gui.set_text()
函数。function on_message(self, message_id, message, sender)
if message_id == hash("set_score") then
local s = gui.get_node("score")
gui.set_text(s, message.score)
end
end
Did you spot an error or do you have a suggestion? Please let us know on GitHub!
GITHUB