Skip to content

Commit 612db78

Browse files
committed
Added AnimationJSON Loader File type.
Fixed ToJSON component.
1 parent fa4192e commit 612db78

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

v3/src/animation/manager/components/ToJSON.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var ToJSON = function (key)
22
{
3-
if (key !== undefined)
3+
if (key !== undefined && key !== '')
44
{
55
return this.anims.get(key).toJSON();
66
}
@@ -11,9 +11,9 @@ var ToJSON = function (key)
1111
globalTimeScale: this.globalTimeScale
1212
};
1313

14-
this.anims.each(function (key, anim)
14+
this.anims.each(function (animationKey, animation)
1515
{
16-
output.anims.push(anim.toJSON());
16+
output.anims.push(animation.toJSON());
1717
});
1818

1919
return output;

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: 'eae2f6e0-1f7f-11e7-80fd-a118a22c105c'
2+
build: 'd62d2ed0-1f8b-11e7-b52d-db08b948d03e'
33
};
44
module.exports = CHECKSUM;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var JSONFile = require('./JSONFile.js');
2+
3+
var AnimationJSONFile = function (key, url, path, xhrSettings)
4+
{
5+
var json = new JSONFile(key, url, path, xhrSettings);
6+
7+
// Override the File type
8+
json.type = 'animationJSON';
9+
10+
return json;
11+
};
12+
13+
module.exports = AnimationJSONFile;

v3/src/state/systems/Loader.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var BaseLoader = require('../../loader/BaseLoader');
33
var NumberArray = require('../../utils/array/NumberArray');
44

55
var ImageFile = require('../../loader/filetypes/ImageFile');
6+
var AnimationJSONFile = require('../../loader/filetypes/AnimationJSONFile');
67
var JSONFile = require('../../loader/filetypes/JSONFile');
78
var XMLFile = require('../../loader/filetypes/XMLFile');
89
var BinaryFile = require('../../loader/filetypes/BinaryFile');
@@ -88,6 +89,13 @@ Loader.prototype.image = function (key, url, xhrSettings)
8889
return this.addFile(file);
8990
};
9091

92+
Loader.prototype.animation = function (key, url, xhrSettings)
93+
{
94+
var file = new AnimationJSONFile(key, url, this.path, xhrSettings);
95+
96+
return this.addFile(file);
97+
};
98+
9199
Loader.prototype.json = function (key, url, xhrSettings)
92100
{
93101
var file = new JSONFile(key, url, this.path, xhrSettings);
@@ -230,6 +238,7 @@ Loader.prototype.processCallback = function ()
230238
// The global Texture Manager
231239
var cache = this.state.sys.cache;
232240
var textures = this.state.sys.textures;
241+
var anims = this.state.sys.anims;
233242

234243
// Process multiatlas groups first
235244

@@ -279,10 +288,19 @@ Loader.prototype.processCallback = function ()
279288
}
280289
}
281290

291+
// Process all of the files
292+
293+
// Because AnimationJSON may require images to be loaded first, we process them last
294+
var animJSON = [];
295+
282296
this.storage.each(function (file)
283297
{
284298
switch (file.type)
285299
{
300+
case 'animationJSON':
301+
animJSON.push(file);
302+
break;
303+
286304
case 'image':
287305
case 'svg':
288306
case 'html':
@@ -351,6 +369,11 @@ Loader.prototype.processCallback = function ()
351369
}
352370
});
353371

372+
animJSON.forEach(function (file)
373+
{
374+
anims.fromJSON(file.data);
375+
});
376+
354377
this.storage.clear();
355378
};
356379

0 commit comments

Comments
 (0)