Phaser API Documentation

  Version: 
Filter
Namespace: BitmapText
Phaser.Types.GameObjects.BitmapText

Type Definitions

BitmapFontCharacterData
Focus
Focus

Description:

The font data for an individual character of a Bitmap Font.

Describes the character's position, size, offset and kerning.

As of version 3.50 it also includes the WebGL texture uv data.

Properties:
name type description
x number

The x position of the character.

y number

The y position of the character.

width number

The width of the character.

height number

The height of the character.

centerX number

The center x position of the character.

centerY number

The center y position of the character.

xOffset number

The x offset of the character.

yOffset number

The y offset of the character.

u0 number

WebGL texture u0.

v0 number

WebGL texture v0.

u1 number

WebGL texture u1.

v1 number

WebGL texture v1.

data object

Extra data for the character.

kerning Object.<number>

Kerning values, keyed by character code.

Type:
object
Focus
Focus
BitmapFontData
Focus
Focus

Description:

Bitmap Font data that can be used by a BitmapText Game Object.

Properties:
name type description
font string

The name of the font.

size number

The size of the font.

lineHeight number

The line height of the font.

retroFont boolean

Whether this font is a retro font (monospace).

chars Object.<number, Phaser.Types.GameObjects.BitmapText.BitmapFontCharacterData>

The character data of the font, keyed by character code. Each character datum includes a position, size, offset and more.

Type:
object
Focus
Focus
BitmapTextCharacter
Focus
Focus

Description:

A single entry from the BitmapTextSize characters array.

The position and dimensions take the font size into account, but are not translated into the local space of the Game Object itself.

Properties:
name type description
i number

The index of this character within the BitmapText wrapped text string.

idx number

The index of this character within the BitmapText text string.

char string

The character.

code number

The character code of the character.

x number

The x position of the character in the BitmapText.

y number

The y position of the character in the BitmapText.

w number

The width of the character.

h number

The height of the character.

t number

The top of the line this character is on.

r number

The right-most point of this character, including xAdvance.

b number

The bottom of the line this character is on.

line number

The line number the character appears on.

glyph Phaser.Types.GameObjects.BitmapText.BitmapFontCharacterData

Reference to the glyph object this character is using.

Type:
object
Focus
Focus
BitmapTextConfig
Focus
Focus
Properties:
name type arguments Default description
font string <optional> ''

The key of the font to use from the BitmapFont cache.

text string <optional> ''

The string, or array of strings, to be set as the content of this Bitmap Text.

size number | false <optional> false

The font size to set.

Type:
object
Focus
Focus
BitmapTextLines
Focus
Focus

Description:

Details about the line data in the BitmapTextSize object.

Properties:
name type description
shortest number

The width of the shortest line of text.

longest number

The width of the longest line of text.

height number

The height of a line of text.

lengths Array.<number>

An array where each entry contains the length of that line of text.

Type:
object
Focus
Focus
BitmapTextSize
Focus
Focus
Properties:
name type description
global Phaser.Types.GameObjects.BitmapText.GlobalBitmapTextSize

The position and size of the BitmapText, taking into account the position and scale of the Game Object.

local Phaser.Types.GameObjects.BitmapText.LocalBitmapTextSize

The position and size of the BitmapText, taking just the font size into account.

lines Phaser.Types.GameObjects.BitmapText.BitmapTextLines

Data about the lines of text within the BitmapText.

characters Array.<Phaser.Types.GameObjects.BitmapText.BitmapTextCharacter>

An array containing per-character data. Only populated if includeChars is true in the getTextBounds call.

words Array.<Phaser.Types.GameObjects.BitmapText.BitmapTextWord>

An array containing the word data from the BitmapText.

scale number

The scale of the BitmapText font being rendered vs. font size in the text data.

scaleX number

The scale X value of the BitmapText.

scaleY number

The scale Y value of the BitmapText.

wrappedText string

The wrapped text, if wrapping enabled and required.

Type:
object
Focus
Focus
BitmapTextWord
Focus
Focus

Description:

Details about a single world entry in the BitmapTextSize object words array.

Properties:
name type description
x number

The x position of the word in the BitmapText.

y number

The y position of the word in the BitmapText.

w number

The width of the word.

h number

The height of the word.

i number

The index of the first character of this word within the entire string. Note: this index factors in spaces, quotes, carriage-returns, etc.

word string

The word.

Type:
object
Focus
Focus
DisplayCallbackConfig
Focus
Focus
Properties:
name type description
parent Phaser.GameObjects.DynamicBitmapText

The Dynamic Bitmap Text object that owns this character being rendered.

tint Phaser.Types.GameObjects.BitmapText.TintConfig

The tint of the character being rendered. Always zero in Canvas.

index number

The index of the character being rendered.

charCode number

The character code of the character being rendered.

x number

The x position of the character being rendered.

y number

The y position of the character being rendered.

scale number

The scale of the character being rendered.

rotation number

The rotation of the character being rendered.

data any

Custom data stored with the character being rendered.

Type:
object
Focus
Focus
DisplayCallback(display)
Focus
Focus

Parameters:

name type description
display Phaser.Types.GameObjects.BitmapText.DisplayCallbackConfig

Settings of the character that is about to be rendered.

Type:
function
Returns:
Description:

Altered position, scale and rotation values for the character that is about to be rendered.

Focus
Focus
GlobalBitmapTextSize
Focus
Focus

Description:

The position and size of the Bitmap Text in global space, taking into account the Game Object's scale and world position.

Properties:
name type description
x number

The x position of the BitmapText, taking into account the x position and scale of the Game Object.

y number

The y position of the BitmapText, taking into account the y position and scale of the Game Object.

width number

The width of the BitmapText, taking into account the x scale of the Game Object.

height number

The height of the BitmapText, taking into account the y scale of the Game Object.

Type:
object
Focus
Focus
JSONBitmapText
Focus
Focus
Properties:
name type description
font string

The name of the font.

text string

The text that this Bitmap Text displays.

fontSize number

The size of the font.

letterSpacing number

Adds / Removes spacing between characters.

lineSpacing number

Adds / Removes spacing between lines in multi-line text.

align number

The alignment of the text in a multi-line BitmapText object.

Type:
object
Focus
Focus
LocalBitmapTextSize
Focus
Focus

Description:

The position and size of the Bitmap Text in local space, taking just the font size into account.

Properties:
name type description
x number

The x position of the BitmapText.

y number

The y position of the BitmapText.

width number

The width of the BitmapText.

height number

The height of the BitmapText.

Type:
object
Focus
Focus
RetroFontConfig
Focus
Focus
Properties:
name type description
image string

The key of the image containing the font.

offset.x number

If the font set doesn't start at the top left of the given image, specify the X coordinate offset here.

offset.y number

If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here.

width number

The width of each character in the font set.

height number

The height of each character in the font set.

chars string

The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements.

charsPerRow number

The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth.

spacing.x number

If the characters in the font set have horizontal spacing between them set the required amount here.

spacing.y number

If the characters in the font set have vertical spacing between them set the required amount here.

lineSpacing number

The amount of vertical space to add to the line height of the font.

Type:
object
Focus
Focus
TintConfig
Focus
Focus
Properties:
name type description
topLeft number

The top left tint value. Always zero in canvas.

topRight number

The top right tint value. Always zero in canvas.

bottomLeft number

The bottom left tint value. Always zero in canvas.

bottomRight number

The bottom right tint value. Always zero in canvas.

Type:
object
Focus
Focus