Text

new Text()

Text component allows to display text on UI elements. This is a UI component, so it should be added to an entity with a UITransform component.

Properties
NameTypeDefaultDescription
textstring"Hello,

World!" - The text to display.

fontFont20px

Arial bold - The font to use.

alignText.ALIGNText.ALIGN_CENTER

The alignment of the text.

colorColorColor.white

The color of the text.

Example
let text = new Text("Hello World!", new Font(), Text.ALIGN_LEFT, Color.white);

Extends

Members

(static, readonly) ALIGN :string

Align the text

Type:
  • string
Properties
NameTypeDescription
LEFTstring
CENTERstring
RIGHTstring
STARTstring
ENDstring

align :string

Align the text.

ValueDescription
Text.ALIGN_LEFTAlign the text to the left.
Text.ALIGN_CENTERAlign the text to the center.
Text.ALIGN_RIGHTAlign the text to the right.
Text.ALIGN_STARTAlign the text to the start.
Text.ALIGN_ENDAlign the text to the end.
Type:
  • string

blendMode

Blend mode of the object

Inherited From

color :Color

The text color to be used.

Type:

filter

The filter applied to the object

Inherited From

font :Font

Font the text should be displayed in. The all fonts supported by the browser/HTML5 canvas can be used. Example: "30px Arial bold"

Type:

(readonly) properties

The entity that this component is attached to.

Inherited From

text :string

The text to display.

Type:
  • string