Label
Description:
A node for rendering text using a TrueType font.
Class Object: Label Class.
Inherits from: Node.
Label.TextAlign
Type: Enumeration.
Description:
Enumeration for text alignment setting.
Signature:
enum TextAlign
"Left"
"Center"
"Right"
end
alphaRef
Type: Field.
Description:
The alpha threshold value. Pixels with alpha values below this value will not be drawn.
Only works with label.effect = SpriteEffect("builtin:vs_sprite", "builtin:fs_spritealphatest")
.
Signature:
alphaRef: number
textWidth
Type: Field.
Description:
The width of the text used for text wrapping.
Set to Label.AutomaticWidth
to disable wrapping.
Default is Label.AutomaticWidth
.
Signature:
textWidth: number
lineGap
Type: Field.
Description:
The gap in pixels between lines of text.
Signature:
lineGap: number
spacing
Type: Field.
Description:
The gap in pixels between characters.
Signature:
spacing: number
outlineWidth
Type: Field.
Description:
The width of the outline, only works with SDF label.
Signature:
outlineWidth: number
outlineColor
Type: Field.
Description:
The color of the outline, only works with SDF label.
Signature:
outlineColor: Color
smooth
Type: Field.
Description:
The smooth value of the text, only works with SDF label, default is (0.7, 0.7).
Signature:
smooth: Vec2
text
Type: Field.
Description:
The text to be rendered.
Signature:
text: string
blendFunc
Type: Field.
Description:
The blend function used to render the text.
Signature:
blendFunc: BlendFunc
depthWrite
Type: Field.
Description:
Whether depth writing is enabled. (Default is false)
Signature:
depthWrite: boolean
batched
Type: Field.
Description:
Whether the label is using batched rendering.
When using batched rendering the label:getCharacter()
function will no longer work, and getting better rendering performance. (Default is true)
Signature:
batched: boolean
effect
Type: Field.
Description:
The sprite effect used to render the text.
Signature:
effect: SpriteEffect
alignment
Type: Field.
Description:
The text alignment setting.
Signature:
alignment: TextAlign
characterCount
Type: Readonly Field.
Description:
The number of characters in the label.
Signature:
const characterCount: integer
getCharacter
Type: Function.
Description:
Returns the sprite for the character at the specified index.
Signature:
getCharacter: function(self: Label, index: integer): Sprite | nil
Parameters:
Parameter | Type | Description |
---|---|---|
index | integer | The index of the character sprite to retrieve. |
Returns:
Return Type | Description |
---|---|
Sprite|nil | The sprite for the character, or nil if the index is out of range. |