dot big bang

Developer API
Menu

Class UITextElement

All
  • Public
  • Public/Protected
  • All

Hierarchy

Index

Constructors

constructor

Methods

getColor

  • Get the color of the text being displayed by this element.

    Parameters

    • Optional optionalTarget: Color

      If provided, returns the color into this object rather than allocating a new one.

    Returns Color

getExtents

  • Gets the 2d size of the element in normalized coordinates, also known as UI-position units. For example, a size of (0.5, 1) would indicate an element that covers half the screen horizontally and the whole screen vertically.

    Parameters

    Returns Vector2

getOpacity

  • getOpacity(): number
  • Gets the opacity of the text displayed by this element.

    Returns a number in the range 0 to 1. 0 indicates fully transparent, 1 indicates fully opaque.

    Returns number

getPosition

  • Returns the position in UI-position units of the element.

    Parameters

    • Optional optionalTarget: Vector2

      If provided, return the position in this object rather than allocating a new one.

    Returns Vector2

getRotation

  • getRotation(): number

getSize

  • getSize(): number
  • Gets the size of the element in UI-size units. Note that it is not recommended to use this in combination with setSize2D.

    Returns number

getSize2D

  • Gets the 2d size of the element in UI-size units. For example, a size of (2, 1) would indicate an element that has the default height and twice the default width.

    Parameters

    Returns Vector2

getText

  • getText(): string
  • Returns the text currently displayed by this text element.

    Returns string

isVisible

  • isVisible(): boolean
  • Indicates whether this element is visible or not.

    Returns boolean

setColor

  • setColor(color: Color): void
  • Sets the color of the text displayed by this element.

    Parameters

    Returns void

setExtents

  • Sets the 2d size of the element in normalized coordinates, also known as UI-position units. For example, a size of (0.5, 1) would indicate an element that covers half the screen horizontally and the whole screen vertically. Note: this will affect the same internal state as setSize. Note: If the window/canvas changes size, you will need to call this again.

    Parameters

    Returns Vector2

setOpacity

  • setOpacity(opacity: number): void
  • Sets the opacity of the text displayed by this element.

    Parameters

    • opacity: number

      The desired opacity; a number in the range 0 to 1. 0 indicates fully transparent, 1 indicates fully opaque.

    Returns void

setPosition

  • setPosition(position: Vector2): void
  • Sets the position of this element, in UI-position units.

    Parameters

    • position: Vector2

      The position, in UI-position units.

    Returns void

setRotation

  • setRotation(angle: number): void
  • Set the rotation in radians.

    Parameters

    • angle: number

    Returns void

setSize

  • setSize(size: number): void
  • Sets the size of the element in UI-size units. This will make the element uniformly scaled on both the X and Y axis.

    Parameters

    • size: number

    Returns void

setSize2D

  • Sets the 2d size of the element in UI-size units. For example, a size of (2, 1) would indicate an element that has the default height and twice the default width. Passing in (1, 1) is equivalent to calling setSize(1).

    Parameters

    Returns void

setText

  • setText(text: string): void
  • Sets the text that this element displays.

    Parameters

    • text: string

    Returns void

setVisible

  • setVisible(visible: boolean): void
  • Sets the visibility of the element (i.e. hide or show) in the UI.

    Parameters

    • visible: boolean

      Use true to show the element or false to hide it.

    Returns void