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
+39
View File
@@ -67,6 +67,12 @@ Phaser.Cache = function (game) {
*/
this._bitmapDatas = {};
/**
* @property {object} _bitmapFont - BitmapFont key-value container.
* @private
*/
this._bitmapFont = {};
this.addDefaultImage();
this.addMissingImage();
@@ -134,6 +140,19 @@ Phaser.Cache.prototype = {
},
/**
* Add a Phaser.BitmapFont in to the cache.
*
* @method Phaser.Cache#addBitmapFont
* @param {string} key - The unique key by which you will reference this object.
* @param {Phaser.BitmapFont} texture - The BitmapFont object to be stored. This can be applied to any Image/Sprite as a texture.
*/
addBitmapFont: function (key, texture) {
this._bitmapFont[key] = texture;
},
/**
* Add a new sprite sheet in to the cache.
*
@@ -450,6 +469,26 @@ Phaser.Cache.prototype = {
},
/**
* Get a BitmapFont object from the cache by its key.
*
* @method Phaser.Cache#getBitmapFont
* @param {string} key - Asset key of the BitmapFont object to retrieve from the Cache.
* @return {Phaser.BitmapFont} The requested BitmapFont object if found, or null if not.
*/
getBitmapFont: function (key) {
if (this._bitmapFont[key])
{
return this._bitmapFont[key];
}
else
{
console.warn('Phaser.Cache.getBitmapFont: Invalid key: "' + key + '"');
}
},
/**
* Checks if an image key exists.
*