Merge pull request #3292 from CodeAndWeb/master

Support MultiAtlas with TexturePackers "Phaser 3" atlas format
This commit is contained in:
Richard Davey 2018-03-05 12:17:24 +00:00 committed by GitHub
commit c74ad8dee2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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;