Class: GameText

GameText(text, attrs)

Text drawable class.

Constructor

new GameText(text, attrs)

Constructor of Text drawable

Parameters:
Name Type Default Description
text string sample text

Displayed text

attrs Object

Attribute object

Properties:
Name Type Description
color string

Color of text. Can be CSS color.

text string

Text to display. Can be only 1 line

font string

Font (and size) of the text. Default "20px arial"

maxWidth number

Shrink text width to this size

Source:

Extends

Methods

copy(newName) → {GameText}

Returns copy of current instance.

Parameters:
Name Type Description
newName string

Name of the newly created instance. Names have to be unique.

Overrides:
Source:
Returns:

New instance of GameText with the same attributes.

Type
GameText

draw(ctx)

Transforms input context and calls draw function of passed drawable.

Parameters:
Name Type Description
ctx CanvasRenderingContext2D

Rendering context.

Overrides:
Source:

drawFunction(ctx)

Called when drawing

Parameters:
Name Type Description
ctx CanvasRenderingContext2D

Rendering context on which the method draws

Overrides:
Source:

getAttrs() → {Object}

Returns object of attributes of current instance.

Overrides:
Source:
Returns:

Attribute object.

Type
Object

measureText(ctx) → {TextMetrics}

Returns measures of the drawable

Parameters:
Name Type Description
ctx CanvasRenderingContext2D

Rendering context upon which the calculations are made

Source:
Returns:

text metrics

Type
TextMetrics