Skip to content

Commit 4e49a9b

Browse files
authored
Merge pull request phaserjs#3357 from delftswa2018/3268-object-based-atlas-loading
Fixed object based atlas loading
2 parents 063d306 + 5c64404 commit 4e49a9b

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/loader/filetypes/AtlasJSONFile.js

Lines changed: 17 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,26 @@ 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+
66+
// If param key is an object, use object based loading method
67+
if ((typeof key === 'object') && (key !== null))
68+
{
69+
files = new AtlasJSONFile(key.key, key.texture, key.data, this.path, textureXhrSettings, atlasXhrSettings);
70+
}
71+
72+
// Else just use the parameters like normal
73+
else
74+
{
75+
// Returns an object with two properties: 'texture' and 'data'
76+
files = new AtlasJSONFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings);
77+
}
6578

6679
this.addFile(files.texture);
6780
this.addFile(files.data);

0 commit comments

Comments
 (0)