Class: BitmapFont

me. BitmapFont

new BitmapFont(font, image, scale, textAlign, textBaseline)

a bitmap font object
Parameters:
Name Type Argument Default Description
font Object the font object data. Should be retrieved from the loader
image Image the font image itself Should be retrieved from the loader
scale Number <optional>
1.0
textAlign String <optional>
"left"
textBaseline String <optional>
"top"
Source:
bitmapfont.js, line 53
Example
// Use me.loader.preload or me.loader.load to load assets
me.loader.preload([
{ name: "arial", type: "binary" src: "data/font/arial.fnt" },
{ name: "arial", type: "image" src: "data/font/arial.png" },
])
// Then create an instance of your bitmap font:
var myFont = new me.BitmapFont(me.loader.getBinary("arial"), me.loader.getImage("arial"));
// And draw it inside your Renderable, just like me.Font
myFont.draw(renderer, "Hello!", 0, 0);

Extends

Members

<static> bitmapFontData :me.BitmapFontData

The instance of me.BitmapFontData
Type:
Source:
bitmapfont.js, line 63

alpha :Number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn
Type:
  • Number
Inherited From:
Default Value:
  • 1.0
Source:
renderable.js, line 151
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container

a reference to the Container object that contains this renderable, or undefined if it has not been added to one.
Type:
Inherited From:
Default Value:
  • undefined
Source:
renderable.js, line 163

Methods

<static> draw(renderer, text, x, y)

draw a text at the specified coord
Parameters:
Name Type Description
renderer me.CanvasRenderer | me.WebGLRenderer Reference to the destination renderer instance
text String
x Number
y Number
Source:
bitmapfont.js, line 134

<static> measureText(text) → {Object}

measure the given text size in pixels
Parameters:
Name Type Description
text String
Source:
bitmapfont.js, line 113
Returns:
an object with two properties: `width` and `height`, defining the output dimensions
Type
Object

<static> resize(scale)

change the font display size
Parameters:
Name Type Description
scale Number ratio
Source:
bitmapfont.js, line 101

<static> set(textAlign, scale)

change the font settings
Parameters:
Name Type Argument Description
textAlign String ("left", "center", "right")
scale Number <optional>
Source:
bitmapfont.js, line 85
Copyright © 2011 - 2017, Olivier Biot, Jason Oster, Aaron McLeod
Documentation generated by JSDoc 3.4.0 on 2017-02-28T11:37:40+08:00 using the DocStrap template modified by codename-.