API Docs for: 1.4.0
Show:

Text Class

Extends Sprite
Module: PIXI

A Text Object will create a line(s) of text to split a line you can use '\n'

Constructor

Text

(
  • text
  • [style]
)

Parameters:

  • text String

    The copy that you would like the text to display

  • [style] Object optional

    The style parameters

    • [font] String optional

      default 'bold 20pt Arial' The style and size of the font

    • [fill='black'] Object optional

      A canvas fillstyle that will be used on the text eg 'red', '#00FF00'

    • [align='left'] String optional

      An alignment of the multiline text ('left', 'center' or 'right')

    • [stroke] String optional

      A canvas fillstyle that will be used on the text stroke eg 'blue', '#FCFF00'

    • [strokeThickness=0] Number optional

      A number that represents the thickness of the stroke. Default is 0 (no stroke)

    • [wordWrap=false] Boolean optional

      Indicates if word wrap should be used

    • [wordWrapWidth=100] Number optional

      The width at which text will wrap

Methods

destroy

(
  • destroyTexture
)

Destroys this text object

Parameters:

  • destroyTexture Boolean

setStyle

(
  • [style]
  • [style.font='bold
)

Set the style of the text

Parameters:

  • [style] Object optional

    The style parameters

    • [fill='black'] Object optional

      A canvas fillstyle that will be used on the text eg 'red', '#00FF00'

    • [align='left'] String optional

      An alignment of the multiline text ('left', 'center' or 'right')

    • [stroke='black'] String optional

      A canvas fillstyle that will be used on the text stroke eg 'blue', '#FCFF00'

    • [strokeThickness=0] Number optional

      A number that represents the thickness of the stroke. Default is 0 (no stroke)

    • [wordWrap=false] Boolean optional

      Indicates if word wrap should be used

    • [wordWrapWidth=100] Number optional

      The width at which text will wrap

  • [style.font='bold String

    20pt Arial'] The style and size of the font

setText

(
  • text
)

Set the copy for the text object. To split a line you can use '\n'

Parameters:

  • text String

    The copy that you would like the text to display

updateText

() private

Renders text

updateTexture

() private

Updates texture size based on canvas size

updateTransform

() private

Updates the transfor of this object

wordWrap

(
  • text
)
private

Applies newlines to a string to have it optimally fit into the horizontal bounds set by the Text object's wordWrapWidth property.

Parameters:

  • text String