/bmfont.enchant.js

A plugin for enchant.js that lets you use bitmap font generated from AngelCode's BMFont easily

Primary LanguageJavaScript

BMFont plugin for enchant.js

bmfont.enchant.js is a plugin for enchant.js that lets you use bitmap font generated from AngelCode's BMFont easily.

How to use bmfont.enchant.js

  1. Download AngelCode's BMFont

  2. Set the export setting to output XML file

  3. Create a font, and you will get font_name.fnt and font_name_0.png, put these files in your game folder

  4. Include bmfont.enchant.js into your HTML file.

  5. 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']);
  1. 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);