mirror of
https://github.com/wassname/phaser.git
synced 2026-07-19 11:26:26 +08:00
BitmapFont fixes and updates and Cache support for it added. Working sweet now.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user