bmfont.enchant.js is a plugin for enchant.js that lets you use bitmap font generated from AngelCode's BMFont easily.
-
Download AngelCode's BMFont
-
Set the export setting to output XML file
-
Create a font, and you will get font_name.fnt and font_name_0.png, put these files in your game folder
-
Include bmfont.enchant.js into your HTML file.
-
To use a font, you have to register a font first. The following code will register the font under the name 'score'
enchant.bmfont.createFont('score', 'res/font.fnt', game.assets['res/font_0.png']);
- Create an instance of a FontSprite class to use the created bitmap font.
var bmLabel = new FontSprite('score', 100, 25, "100pts.");
bmLabel.x = 160;
bmLabel.y = 64;
bmLabel.opacity = 0.5; // FontSprite can be used like Sprite class
bmLabel.text = "Hello, World";
scene.addChild(bmLabel);