dot big bang

Developer API
Menu

Class TextComponent

All
  • Public
  • Public/Protected
  • All

Hierarchy

Index

Constructors

constructor

Properties

align

The alignment of the text within the box defined by the width property and the number of lines necessary to display the text. This property has no effect when width is not defined (i.e set to a negative value).

Readonly backgroundColor

backgroundColor: Color

The color of the background plane.

backgroundOpacity

backgroundOpacity: number

The opacity of the background plane between 0 (fully transparent) and 1 (opaque).

backgroundPadding

backgroundPadding: number

The amount of background plane to keep around the text area as padding. This a multiplying factor of the text area size.

Readonly color

color: Color

The color of the text.

enabled

enabled: boolean

Whether the text should be rendered or not.

fontFace

fontFace: null | Font

The Font to use for rendering the text.

Readonly id

id: string

The 36-character identifier string of the Component. The id is unique within the Entity is belongs to. Currently, the same id may be used by another Component on a different Entity.

ignoreFog

ignoreFog: boolean

Whether the text and background are hidden when inside fog See this.game.renderer.fog for more info on fog

isWorldOffset

isWorldOffset: boolean

If true, the offset is expressed along the world-space axes (going through the origin of the Entity). If false, the offset is expressed along the local axes of the Entity. Look at offset property for more information.

letterSpacing

letterSpacing: number

The spacing, in font-pixels, to use between characters in the rendered text.

lineHeight

lineHeight: number

The height, in font-pixels, between rendered lines of texts (when overrideLineHeight is true).

offset

offset: Vector3

The offset from the Entity origin where the text should be rendered. If isWorldOffset is true, that axes is in world-space (going through the origin of the Entity). If it is false, it is the local axes of the Entity. The value of the offset is expressed in the local Entity's space unit. The scale property has no effect on the offset (only on the size of the text and optional background plane displayed at that position).

opacity

opacity: number

The opacity of the text between 0 (fully transparent) and 1 (opaque).

overrideLineHeight

overrideLineHeight: boolean

Whether the lineHeight property should be used instead of the default value associated with the Font.

scale

scale: number

The scaling factor, relative to the Entity, to apply to the rendered text and its optional background plane. This property doesn't affect the yOffset which is always expressed in the local Entity's space unit.

showBackground

showBackground: boolean

Indicates whether to show the single-color background plane behind the text.

tabSize

tabSize: number

The number of space characters to use for each tab character in the text.

text

text: string

The string of text to be displayed. This can contain newline ('\n') or tab characters ('\t').

textBoxHorizontalAlign

textBoxHorizontalAlign: TextComponentTextBoxHorizontalAlignMode

The horizontal alignment of the text box relative to the offset from the entity origin

textBoxVerticalAlign

textBoxVerticalAlign: TextComponentTextBoxVerticalAlignMode

The vertical alignment of the text box relative to the offset from the entity origin

trackCamera

trackCamera: boolean

Indicates whether to render the text so it always faces the camera. When this is the case, the text box appears on screen, in 2D, with no rotation.

Readonly type

The type of the Component.

visible

visible: boolean

Whether the text should be rendered or not.

width

width: number

The width, in font-pixels, within which the text is laid out. This property has no effect when TextComponentWrapMode.OnlyWrapOnNewLine wrapping mode is used. A negative value means that no width is defined. When this is the case, width isn't taken into account for laying out the text (in TextComponentWrapMode.Default and TextComponentWrapMode.StrictlyRespectSpacing modes). Note that the height of the box where the text is laid out depends on the number of lines necessary to display the text.

wrapping

The word-wrapping mode to use for laying out the text.

Accessors

entity

  • Gets the Entity the Component is part of. This throws an exception if the Component is not in an Entity. Use the isInEntity property to test for that.

    Returns Entity

game

  • Gets the Game the Component is part of (via the Entity it belongs to). This throws an exception if the Component is not in the game. Use the isInGame property to test for that.

    Returns Game<{ saveData: SaveData<any, any> }>

isInEntity

  • get isInEntity(): boolean
  • Returns true if the Component is part of an Entity.

    Returns boolean

isInGame

  • get isInGame(): boolean
  • Returns true if the Component is part of the Game (via the Entity it belongs to).

    Returns boolean

worldOffset

  • get worldOffset(): boolean
  • set worldOffset(value: boolean): void
  • If true, the yOffset is expressed along the world-space Y axis (going through the origin of the Entity). If false, the yOffset is expressed along the local Y axis of the Entity. Look at yOffset property for more information.

    Returns boolean

  • If true, the yOffset is expressed along the world-space Y axis (going through the origin of the Entity). If false, the yOffset is expressed along the local Y axis of the Entity. Look at yOffset property for more information.

    Parameters

    • value: boolean

    Returns void

yOffset

  • get yOffset(): number
  • set yOffset(value: number): void
  • The vertical offset along the Y axis, where the text should be rendered. If worldOffset is true, that axis is the world-space Y axis (going through the origin of the Entity). If it is false, it is the local Y axis of the Entity. The value of the offset is expressed in the local Entity's space unit. The scale property has no effect on the yOffset (only on the size of the text and optional background plane displayed at that position).

    Returns number

  • The vertical offset along the Y axis, where the text should be rendered. If worldOffset is true, that axis is the world-space Y axis (going through the origin of the Entity). If it is false, it is the local Y axis of the Entity. The value of the offset is expressed in the local Entity's space unit. The scale property has no effect on the yOffset (only on the size of the text and optional background plane displayed at that position).

    Parameters

    • value: number

    Returns void