GameObjectCreator#retroFont()

retroFont(font, characterWidth, characterHeight, chars, charsPerRow, xSpacing, ySpacing, xOffset, yOffset) → {Phaser.RetroFont}

Create a new RetroFont object.

A RetroFont can be used as a texture for an Image or Sprite and optionally add it to the Cache.
A RetroFont uses a bitmap which contains fixed with characters for the font set. You use character spacing to define the set.
If you need variable width character support then use a BitmapText object instead. The main difference between a RetroFont and a BitmapText
is that a RetroFont creates a single texture that you can apply to a game object, where-as a BitmapText creates one Sprite object per letter of text.
The texture can be asssigned or one or multiple images/sprites, but note that the text the RetroFont uses will be shared across them all,
i.e. if you need each Image to have different text in it, then you need to create multiple RetroFont objects.

Parameters
Name Type Argument Default Description
font string

The key of the image in the Game.Cache that the RetroFont will use.

characterWidth number

The width of each character in the font set.

characterHeight 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.

xSpacing number <optional>
0

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

ySpacing number <optional>
0

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

xOffset number <optional>
0

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

yOffset number <optional>
0

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

Returns

The newly created RetroFont texture which can be applied to an Image or Sprite.

Source code: gameobjects/GameObjectCreator.js (Line 269)
doc_phaser
2017-02-14 10:48:32
Comments
Leave a Comment

Please login to continue.