TextSprite Class

Extends CanvasSprite
Module: Meshes

Text sprite is used to represent text as a sprite.

This approach is memory expensive since it needs to write a new texture for each text. But allows the used to access any font available in the browser.

The text is rendered to canvas and then copied to a texture. It automatically ajusts the object scale to match the text aspect.

Methods

drawText

()

Update the canvas texture, redrawText text into the canvas.

Attributes

align

String

Horizontal text alignment can be

  • TextSprite.LEFT
  • TextSprite.RIGHT
  • TextSprite.CENTER

CENTER

String static

Align text to the center.

color

String

CSS color of the text.

font

String

CSS Font style to be used.

LEFT

String static

Align text to the left side.

outline

Boolean

Indicates if the text has an outline border.

outlineColor

String

CSS color of the outline.

outlineWidth

Number

Width of the text outline.

resolution

Number

Vertical resolution of the texture created from canvas used.

Should always be a npot of 2.

RIGHT

String static

Align text to the right side.

text

String

Text of this object.