Skip to content

Commit 1e88bdd

Browse files
committed
Loader.bitmapFont wouldn't automatically set the atlasURL value if just the key was given.
1 parent 482d3c9 commit 1e88bdd

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
265265

266266
### Bug Fixes
267267

268+
* Loader.bitmapFont wouldn't automatically set the `atlasURL` value if just the key was given.
268269

269270
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
270271

src/loader/Loader.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,15 +1278,15 @@ Phaser.Loader.prototype = {
12781278
*
12791279
* If the textureURL isn't specified then the Loader will take the key and create a filename from that.
12801280
* For example if the key is "megaFont" and textureURL is null then the Loader will set the URL to be "megaFont.png".
1281-
* The same is true for the xmlURL. If xmlURL isn't specified and no xmlData has been provided then the Loader will
1282-
* set the xmlURL to be the key. For example if the key is "megaFont" the xmlURL will be set to "megaFont.xml".
1281+
* The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will
1282+
* set the atlasURL to be the key. For example if the key is "megaFont" the atlasURL will be set to "megaFont.xml".
12831283
*
12841284
* If you do not desire this action then provide URLs and / or a data object.
12851285
*
12861286
* @method Phaser.Loader#bitmapFont
12871287
* @param {string} key - Unique asset key of the bitmap font.
12881288
* @param {string} textureURL - URL of the Bitmap Font texture file. If undefined or `null` the url will be set to `<key>.png`, i.e. if `key` was "megaFont" then the URL will be "megaFont.png".
1289-
* @param {string} atlasURL - URL of the Bitmap Font atlas file (xml/json).
1289+
* @param {string} atlasURL - URL of the Bitmap Font atlas file (xml/json). If undefined or `null` AND `atlasData` is null, the url will be set to `<key>.xml`, i.e. if `key` was "megaFont" then the URL will be "megaFont.xml".
12901290
* @param {object} atlasData - An optional Bitmap Font atlas in string form (stringified xml/json).
12911291
* @param {number} [xSpacing=0] - If you'd like to add additional horizontal spacing between the characters then set the pixel value here.
12921292
* @param {number} [ySpacing=0] - If you'd like to add additional vertical spacing between the lines then set the pixel value here.
@@ -1301,6 +1301,12 @@ Phaser.Loader.prototype = {
13011301

13021302
if (atlasURL === undefined) { atlasURL = null; }
13031303
if (atlasData === undefined) { atlasData = null; }
1304+
1305+
if (atlasURL === null && atlasData === null)
1306+
{
1307+
atlasURL = key + '.xml';
1308+
}
1309+
13041310
if (xSpacing === undefined) { xSpacing = 0; }
13051311
if (ySpacing === undefined) { ySpacing = 0; }
13061312

@@ -1336,6 +1342,7 @@ Phaser.Loader.prototype = {
13361342
}
13371343

13381344
return this;
1345+
13391346
},
13401347

13411348
/**

0 commit comments

Comments
 (0)