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 组件之中. 或者使用右键点击 Fonts 文件夹, 使用 GUI 顶级菜单或者快捷键.
文本节点有一些特有属性:
你可以通过设置锚点来改变文本的对齐方式.
Center
, North
或者 South
, 则文本居中对齐.West
模式, 则文本左对齐.East
模式, 则文本右对齐.文本节点同样可以控制 size, pivot, color 之类的属性. 此外还有一些文本节点特有属性:
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