@@ -19,6 +19,7 @@ var Animation = function (manager, key, config)
1919
2020 if ( this . duration === null && this . frameRate === null )
2121 {
22+ // No duration or frameRate given, use default frameRate of 24fps
2223 this . frameRate = 24 ;
2324 this . duration = this . frameRate / this . frames . length ;
2425 }
@@ -31,7 +32,7 @@ var Animation = function (manager, key, config)
3132 }
3233 else
3334 {
34- // No duration, so derive from the frameRate
35+ // frameRate given, derive duration from it (even if duration also specified)
3536 // I.e. 15 frames in the animation, frameRate = 30 fps
3637 // So duration is 15 / 30 = 0.5 (half a second)
3738 this . duration = this . frames . length / this . frameRate ;
@@ -252,6 +253,31 @@ Animation.prototype = {
252253 }
253254 } ,
254255
256+ toJSON : function ( )
257+ {
258+ var output = {
259+ key : this . key ,
260+ type : 'frame' ,
261+ frames : [ ] ,
262+ framerate : this . frameRate ,
263+ duration : this . duration ,
264+ skipMissedFrames : this . skipMissedFrames ,
265+ delay : this . delay ,
266+ repeat : this . repeat ,
267+ repeatDelay : this . repeatDelay ,
268+ yoyo : this . yoyo ,
269+ showOnStart : this . showOnStart ,
270+ hideOnComplete : this . hideOnComplete
271+ } ;
272+
273+ this . frames . forEach ( function ( frame )
274+ {
275+ output . frames . push ( frame . toJSON ( ) ) ;
276+ } ) ;
277+
278+ return output ;
279+ } ,
280+
255281 destroy : function ( )
256282 {
257283
0 commit comments