Text (Extends from Container)

Module: engine.renderer.text

Text that uses bitmap fonts for rendering.

new game.Text(text, [props])

Parameters:

  • text String
  • props Object (optional)

Properties

_cached Boolean (Default: false)

(No description yet)

_cachedSprite Sprite

(No description yet)

_cosCache Number (Default: 1)

(No description yet)

_interactive Boolean (Default: false)

(No description yet)

_lastTransformUpdate Number

(No description yet)

_lines Object

(No description yet)

_localTransform Matrix

(No description yet)

_parent Container

(No description yet)

_rotationCache Number (Default: 0)

(No description yet)

_sinCache Number (Default: 0)

(No description yet)

_worldAlpha Number (Default: 1)

(No description yet)

_worldBounds Rectangle

(No description yet)

_worldTransform Matrix

(No description yet)

align String

Align for multi-lined text. Can be left, center or right.

alpha Number (Default: 1)

Container opacity, 0 makes it invisible.

anchor Vector

(No description yet)

buttonMode Boolean (Default: false)

Change cursor, when mouse is over the container. Define cursor at game.Input.buttonModeCursor.

cache Boolean (Default: false)

Cache container content as bitmap.

children Array

(No description yet)

font String

Name of the font that this text is using.

fontClass Font

Font class that this text is using.

height Number

(No description yet)

hitArea Rectangle|Circle

(No description yet)

interactive Boolean (Default: false)

(No description yet)

mask Graphics

(No description yet)

maxHeight Number (Default: 0)

If text height is higher than maxHeight value, text will be scaled down to fit maxHeight. 0 to disable.

maxWidth Number (Default: 0)

If text width is higher than maxWidth value, text will be scaled down to fit maxWidth. 0 to disable.

parent Container

(No description yet)

position Vector

(No description yet)

renderable Boolean (Default: true)

(No description yet)

rotation Number (Default: 0)

(No description yet)

scale Vector

(No description yet)

skew Vector

(No description yet)

stage Container

(No description yet)

text String

Current text value.

visible Boolean (Default: true)

Visibility. If set to false, rendering and interactivity will be disabled.

width Number

(No description yet)

wrap Number

If text width is higher than wrap value, text will be wrapped to multiple lines. 0 to disable.

x Number

Shorthand for position.x

y Number

Shorthand for position.y

Methods

_destroyCachedSprite()

(No description yet)

_generateCachedSprite()

(No description yet)

_generateText(width)

(No description yet)

Parameters:

  • width Number
_getBounds() Rectangle

(No description yet)

_worldBounds

_removeStageReference()

(No description yet)

_render(context)

(No description yet)

Parameters:

  • context CanvasRenderingContext2D
_renderCanvas(context)

(No description yet)

Parameters:

  • context CanvasRenderingContext2D
_renderChildren(context)

(No description yet)

Parameters:

  • context CanvasRenderingContext2D
_setStageReference(stage)

(No description yet)

Parameters:

  • stage Container
_updateChildTransform()

(No description yet)

_updateParentTransform()

(No description yet)

addChild(child)

(No description yet)

Parameters:

  • child Container
addChildAt(child, index)

(No description yet)

Parameters:

  • child Container
  • index Number
addTo(container, [index])

Add this to container.

Parameters:

  • container Container
  • index Number (optional)
anchorCenter()

(No description yet)

center(target, [offsetX], [offsetY], [worldPos])

Position container to center of target.

Parameters:

  • target Container
  • offsetX Number (optional)
  • offsetY Number (optional)
  • worldPos Boolean (optional)

    Use world position.

click(x, y, id, event)

(No description yet)

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
hitTest(target) Boolean

Test if container's bounds are overlapping target's bounds.

Parameters:

  • target Container
mousedown(x, y, id, event) Boolean

(No description yet)

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent

Return true, to skip to next object.

mousemove(x, y, id, event) Boolean

(No description yet)

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent

Return true, to skip to next object.

mouseout(x, y, id, event)

(No description yet)

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
mouseover(x, y, id, event)

(No description yet)

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
mouseup(x, y, id, event) Boolean

(No description yet)

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent

Return true, to skip to next object.

mouseupoutside(x, y, id, event)

(No description yet)

Parameters:

  • x Number
  • y Number
  • id Number
  • event MouseEvent|TouchEvent
onScreen() Boolean

Check if container is on the screen.

Return true, if on the screen.

remove()

Remove this from it's parent.

removeAll()

Remove all childrens.

removeChild(child)

Remove children.

Parameters:

  • child Container
setFont(fontName)

Set new font for text.

Parameters:

  • fontName String
setText(text)

Set new text.

Parameters:

  • text String|Number
swap(container)

Swap container position with this container.

Parameters:

  • container Container
swapChildren(child, child2)

Swap position of two childrens.

Parameters:

  • child Container
  • child2 Container
toBottom()

Move container to first children.

toTop()

Move container to last children.

toWorldPosition([vector], [local]) Vector

Get current world position

Parameters:

  • vector Vector (optional)

    Vector to set world position

  • local Boolean (optional)

    Convert world position to local position

Returns new Vector, if vector parameter not defined

updateText()

Update text texture.

updateTransform()

(No description yet)

Attributes

defaultFont String

Default font for text.