mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Check for new TP3 structure.
This commit is contained in:
parent
33a67f3aff
commit
3225367240
2 changed files with 13 additions and 6 deletions
|
@ -277,9 +277,8 @@ var TextureManager = new Class({
|
|||
*/
|
||||
addAtlas: function (key, source, data)
|
||||
{
|
||||
// Is it a Hash or an Array?
|
||||
|
||||
if (Array.isArray(data.frames))
|
||||
// New Texture Packer format?
|
||||
if (Array.isArray(data.textures) || Array.isArray(data.frames))
|
||||
{
|
||||
return this.addAtlasJSONArray(key, source, data);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ var Clone = require('../../utils/object/Clone');
|
|||
var JSONArray = function (texture, sourceIndex, json)
|
||||
{
|
||||
// Malformed?
|
||||
if (!json['frames'])
|
||||
if (!json['frames'] && !json['textures'])
|
||||
{
|
||||
console.warn('Invalid Texture Atlas JSON Array given, missing \'frames\' array');
|
||||
console.warn('Invalid Texture Atlas JSON Array given, missing \'frames\' and \'textures\' array');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,8 @@ 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 = json['frames'];
|
||||
var frames = (Array.isArray(json.textures)) ? json.textures[0].frames : json.frames;
|
||||
|
||||
var newFrame;
|
||||
|
||||
for (var i = 0; i < frames.length; i++)
|
||||
|
@ -57,6 +58,13 @@ var JSONArray = function (texture, sourceIndex, json)
|
|||
newFrame.updateUVsInverted();
|
||||
}
|
||||
|
||||
if (src.anchor)
|
||||
{
|
||||
newFrame.customPivot = true;
|
||||
newFrame.pivotX = src.anchor.x;
|
||||
newFrame.pivotY = src.anchor.y;
|
||||
}
|
||||
|
||||
// Copy over any extra data
|
||||
newFrame.customData = Clone(src);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue