Skip to content

class Label (client-side)

Available since version: 0.3.4

This class represents text visible on the screen.

Constructor

Label(int x, int y, string text)

Parameters:

  • int x: the x position in virtuals.
  • int y: the y position in virtuals.
  • string text: the text to be shown.

Properties

bool visible

Represents the visibility state of the text.


zarray& vertices (read-only)

Represents the array containing the label vertices (1 letter/glyph consists of 6 vertices written in counter clockwise order, where 3 vertices form one triangle).


string text

Represents the text displayed by the label.


string font

Represents the font name used by the text.


Color& color

Represents the text color in RGBA model.


int alphaFunc

Represents the label alpha blending function. For more information see Alpha Functions


float rotation

Note

To change that center of rotation, see setPivotPoint and setPivotPointPx.

Represents the rotation of the text in degrees.
The rotation is performed clockwise around the label pivot point.


int width (read-only)

Represents the width of the text in virtuals.


int widthPx (read-only)

Represents the width of the text in pixels.


int height (read-only)

Represents the height of the text in virtuals.


int heightPx (read-only)

Represents the height of the text in pixels.


int letterSpacing

Represents the spacing between letters in pixels (by default the spacing is loaded from game font, which is set to 1 pixel).


bool linearFilterEnabled (read-only)

Represents true linear filtering is enabled (bilerp or anisotropic, depending on game settings), otherwise false.


bool autoUpdateViewport (read-only)

Represents true if viewport should be automatically recalculated when ui element dimensions are changing, otherwise false.


Vec2i& viewportMin (read-only)

Represents the top-left corner of the UI element's viewport bounds in pixels. This value is automatically updated when autoUpdateViewport is enabled, and reflects the minimum screen-space coordinates enclosing all vertices.


Vec2i& viewportMax (read-only)

Represents the bottom-right corner of the UI element's viewport bounds in pixels. This value is automatically updated when autoUpdateViewport is enabled, and reflects the maximum screen-space coordinates enclosing all vertices.


Methods

top

This method will move the label text at the end of the render queue.
It will be visible at the top of the screen (other elements will be covered by it).

void top()

getScale

This method will get the scale of the text.

Vec2 getScale()

Returns Vec2:

the label scale.


setScale

This method will set the scale of the text.

void setScale(float width, float height)

Parameters:

  • float width: the scale factor on x axis.
  • float height: the scale factor on y axis.

getPosition

This method will get the text position on screen in virtuals.

Vec2i getPosition()

Returns Vec2i:

the label position on screen.


setPosition

This method will set the text position on screen in virtuals.

void setPosition(int x, int y)

Parameters:

  • int x: the x position in virtuals.
  • int y: the y position in virtuals.

getPositionPx

This method will get the text position on screen in pixels.

Vec2i getPositionPx()

Returns Vec2i:

the label position on screen.


setPositionPx

This method will set the text position on screen in pixels.

void setPositionPx(int x, int y)

Parameters:

  • int x: the x position in pixels.
  • int y: the y position in pixels.

getPivotPoint

This method will get the pivot point of the text in virtuals (Offset from the center of the label).

Vec2i getPivotPoint()

Returns Vec2i:

the offset in virtuals. The default pivot point value is {x=0,y=0}


setPivotPoint

This method will set the pivot point of the text in virtuals (Offset from the center of the label).
All rotations will be done relative to this point.

void setPivotPoint(int x, int y)

Parameters:

  • int x: the x offset in virtuals.
  • int y: the y offset in virtuals.

getPivotPointPx

This method will get the pivot point of the text in pixels (Offset from the center of the label).

Vec2i getPivotPointPx()

Returns Vec2i:

the offset in pixels. The default pivot point value is {x=0,y=0}


setPivotPointPx

This method will set the pivot point of the text in pixels (Offset from the center of the label).
All rotations will be done relative to this point.

void setPivotPointPx(int x, int y)

Parameters:

  • int x: the x offset in pixels.
  • int y: the y offset in pixels.

getLetterColor

This method will get the label letter color (1st vertex will be used to retrieve it).

Color getLetterColor()

Returns Color:

the label letter color.


setLetterColor

This method will set the label letter color (all 6 vertices will be updated for given letter).

void setLetterColor(int idx, Color color)

Parameters:

  • int idx: the label letter index.
  • Color color: the new label letter color.

Callbacks

No callbacks.