Skip to content

Text

Text in the world: any project font (or SDF for crisp scaling), wrapping, alignment, rich text ([color=..] [size=..] [wave] [shake]), localization keys and a typewriter reveal.

Type: TextNode · Category: Graphics & Rendering · Also found as: text, label2d, textlabel

Property Type Default Description
text string "Text" The text; rich text markup when Rich Text is on, a locale key when Localized.
font string "" Project font (.ttf / .otf / .fnt; “” = the engine font).
fontSize number 24 Text size (px). Range 4 to 256.
color color #ffffffff Text colour (rich text [color] overrides it).
align enum: Left, Center, Right Left Alignment of the lines within the text block.
maxWidth number 0 Wrap lines at this width (px); 0 = only at line breaks. Range 0 to 4000.
lineSpacing number 1.2 Line height as a multiple of the font size. Range 0.5 to 3.
richText boolean true Interpret [color=..] [size=..] [wave] [shake] tags.
localized boolean false The text is a key in the locale tables; shows the current language’s translation.
sdf boolean false Signed-distance-field rendering: stays sharp when scaled or zoomed (vector fonts).
revealSpeed number 0 Typewriter: characters per second (0 = all at once); emits “revealed” when done. Range 0 to 500.

Plus the common properties every node has.

Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.

Connects a handler to one of this node’s events: revealed (The text finished revealing); the tree events; custom ones.

self.node:connect("revealed", function(value, source) Log.info("revealed") end)
  • event TextNodeEvent|string
  • handler fun(value: any, source: TextNode)

Returns integer id Connection id for disconnect

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("text")
  • path TextNodeProperty|string

Returns any

Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.” a field of the node’s script.

self.node:set_property("text", "text")
  • path TextNodeProperty|string
  • value any
  • y? number

TextNode: types the text out again (revealSpeed > 0).

self.node:get_node("Intro"):text_restart()
{
"type": "TextNode",
"name": "Text",
"position": [
0,
0
],
"properties": {
"text": "Text",
"font": "",
"fontSize": 24
}
}