fixed multiatlas loader to support new TexturePacker atlas format introduced for Phaser 3

This commit is contained in:
Joachim Grill 2018-02-27 14:48:45 +01:00
parent 6b77ca6ae5
commit 22ecd23f09
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 // Yup, add them to the Texture Manager
// Is the data JSON Hash or JSON Array? // 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); textures.addAtlasJSONArray(key, images, data);
} }

View file

@ -314,9 +314,11 @@ var TextureManager = new Class({
if (Array.isArray(data)) 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 else

View file

@ -34,7 +34,7 @@ var JSONArray = function (texture, sourceIndex, json)
texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height);
// By this stage frames is a fully parsed array // 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; var newFrame;