Skip to content

Commit 57d82d9

Browse files
author
Tom Catshoek
committed
Fixed object based atlas loading
1 parent 9a21b4c commit 57d82d9

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/loader/filetypes/AtlasJSONFile.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var AtlasJSONFile = function (key, textureURL, atlasURL, path, textureXhrSetting
4141

4242
/**
4343
* Adds a Texture Atlas file to the current load queue.
44-
*
44+
*
4545
* Note: This method will only be available if the Atlas JSON File type has been built into Phaser.
4646
*
4747
* The file is **not** loaded immediately after calling this method.
@@ -55,13 +55,24 @@ var AtlasJSONFile = function (key, textureURL, atlasURL, path, textureXhrSetting
5555
* @param {string} atlasURL - The url to load the atlas file from.
5656
* @param {object} textureXhrSettings - Optional texture file specific XHR settings.
5757
* @param {object} atlasXhrSettings - Optional atlas file specific XHR settings.
58-
*
58+
*
5959
* @return {Phaser.Loader.LoaderPlugin} The Loader.
6060
*/
6161
FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
6262
{
63-
// Returns an object with two properties: 'texture' and 'data'
64-
var files = new AtlasJSONFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings);
63+
64+
var files;
65+
// If param key is an object, use object based loading method
66+
if ((typeof key === "object") && (key !== null))
67+
{
68+
files = new AtlasJSONFile(key.key, key.texture, key.data, this.path, textureXhrSettings, atlasXhrSettings);
69+
}
70+
// Else just use the parameters like normal
71+
else
72+
{
73+
// Returns an object with two properties: 'texture' and 'data'
74+
files = new AtlasJSONFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings);
75+
}
6576

6677
this.addFile(files.texture);
6778
this.addFile(files.data);

0 commit comments

Comments
 (0)