Defold supports a specific type of GUI node that allows text to be rendered in a GUI scene. Any font resource added to a project can be used for text node rendering.
The fonts that you wish to use in GUI text nodes must be added to the GUI component. Either right-click the Fonts folder, use the GUI top menu or press the corresponding keyboard shortcut.
Text nodes have a set of special properties:
By setting the node pivot you can change the alignment mode for the text.
Center
, North
or South
, the text is center-aligned.West
modes, the text is left-aligned.East
modes, the text is right-aligned.Text nodes respond to any generic node manipulation functions for setting size, pivot, color and so forth. A few text node only functions exist:
gui.set_font()
function.gui.set_line_break()
function.gui.set_text()
function.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