BitmapFont fixes and updates and Cache support for it added. Working sweet now.

This commit is contained in:
photonstorm
2014-02-14 16:38:06 +00:00
parent ef95fbaa00
commit 539a0f2256
5 changed files with 58 additions and 34 deletions
+6 -4
View File
@@ -462,12 +462,11 @@ Phaser.BitmapFont.prototype.pasteLine = function (line, x, y, customSpacingX) {
else
{
// If the character doesn't exist in the font then we don't want a blank space, we just want to skip it
if (this.grabData[line.charCodeAt(c)])
if (this.grabData[line.charCodeAt(c)] >= 0)
{
this.stamp.frame = this.grabData[line.charCodeAt(c)];
p.set(x, y);
this.render(this.stamp, p, false);
// this.bmd.copyPixels(this.fontSet, this.grabData[line.charCodeAt(c)], x, y);
x += this.characterWidth + this.customSpacingX;
@@ -522,9 +521,12 @@ Phaser.BitmapFont.prototype.removeUnsupportedCharacters = function (stripCR) {
for (var c = 0; c < this._text.length; c++)
{
if (this.grabData[this._text.charCodeAt(c)] || this._text.charCodeAt(c) == 32 || (!stripCR && this._text.charAt(c) === "\n"))
var char = this._text[c];
var code = char.charCodeAt(0);
if (this.grabData[code] >= 0 || (!stripCR && char === "\n"))
{
newString = newString.concat(this._text.charAt(c));
newString = newString.concat(char);
}
}
+5 -2
View File
@@ -258,9 +258,12 @@ Phaser.GameObjectFactory.prototype = {
},
/**
* Create a new BitmapFont object.
* Create a new BitmapFont object to be used as a texture for an Image or Sprite and optionally add it to the Cache.
* The texture can be asssigned or one or multiple images/sprites, but note that the text the BitmapFont 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 BitmapFont objects.
*
* @param {string} font - The key of the BitmapFont as stored in Game.Cache.
* @method Phaser.GameObjectFactory#bitmapFont
* @param {string} font - The key of the image in the Game.Cache that the BitmapFont will use.
* @param {number} characterWidth - The width of each character in the font set.
* @param {number} characterHeight - The height of each character in the font set.
* @param {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements.