diff --git a/src/loader/LoaderPlugin.js b/src/loader/LoaderPlugin.js index 159cbd635..448a93d8c 100644 --- a/src/loader/LoaderPlugin.js +++ b/src/loader/LoaderPlugin.js @@ -656,7 +656,7 @@ var LoaderPlugin = new Class({ // Yup, add them to the Texture Manager // Is the data JSON Hash or JSON Array? - if (Array.isArray(data[0].frames)) + if (Array.isArray(data[0].textures) || Array.isArray(data[0].frames)) { textures.addAtlasJSONArray(key, images, data); } diff --git a/src/textures/TextureManager.js b/src/textures/TextureManager.js index 91ad16486..79f53a4d1 100644 --- a/src/textures/TextureManager.js +++ b/src/textures/TextureManager.js @@ -314,9 +314,11 @@ var TextureManager = new Class({ if (Array.isArray(data)) { - for (var i = 0; i < data.length; i++) + var singleAtlasFile = (data.length === 1); // multi-pack with one atlas file for all images + for (var i = 0; i < texture.source.length; i++) { - Parser.JSONArray(texture, i, data[i]); + var atlasData = singleAtlasFile ? data[0] : data[i]; + Parser.JSONArray(texture, i, atlasData); } } else diff --git a/src/textures/parsers/JSONArray.js b/src/textures/parsers/JSONArray.js index e0f22ee60..a6eef5638 100644 --- a/src/textures/parsers/JSONArray.js +++ b/src/textures/parsers/JSONArray.js @@ -34,7 +34,7 @@ var JSONArray = function (texture, sourceIndex, json) texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); // By this stage frames is a fully parsed array - var frames = (Array.isArray(json.textures)) ? json.textures[0].frames : json.frames; + var frames = (Array.isArray(json.textures)) ? json.textures[sourceIndex].frames : json.frames; var newFrame;