Dev - Lua Libraries

Lua Command: s3sprite.createText

Parameters

Return Values

Signature

int textID = s3sprite.createText(string text, int fontID, int x = 0, int y = 0, order order = 0, int alignment = 0)

Description

Creates a new text on the screen with the font with the given fontID and returns its textID for use with other commands. fontID will be -1 if the creation failed (because fontID does not point to an existing image). Texts are a special kind of sprite. All sprite commands can be applied to texts as well.

The position is specified in pixels and starts with (0|0) in the top left corner of the screen. This is also the default position. A custom position can be specified with the parameters x and y. It is possible to change the position after creation with commands like s3sprite.setPosition.

The order defines the rendering order (and optionally also the sorting layer). Images with a lower order/sorting layer are rendered first.

By default the text will be left-aligned (alignment = 0). It can also be centered (alignment = 1) or right-aligned (alignment = 2).

Note:

textID will be -1 if the text creation failed. This commonly only happens when the specified font does not exist.

Note:

Texts behave like normal sprites. All sprite commands can be used on them.

Note:

See data types: order to learn how orders are specified!