@@ -61,11 +61,20 @@ var Animation = function (manager, key, config)
6161 // Should sprite.visible = false when the animation finishes?
6262 this . hideOnComplete = GetObjectValue ( config , 'hideOnComplete' , false ) ;
6363
64- // Callbacks (swap for Events?)
64+ // Callbacks
65+ this . callbackScope = GetObjectValue ( config , 'callbackScope' , this ) ;
66+
6567 this . onStart = GetObjectValue ( config , 'onStart' , false ) ;
68+ this . onStartParams = GetObjectValue ( config , 'onStartParams' , [ ] ) ;
69+
6670 this . onRepeat = GetObjectValue ( config , 'onRepeat' , false ) ;
71+ this . onRepeatParams = GetObjectValue ( config , 'onRepeatParams' , [ ] ) ;
72+
73+ this . onUpdate = GetObjectValue ( config , 'onUpdate' , false ) ;
74+ this . onUpdateParams = GetObjectValue ( config , 'onUpdateParams' , [ ] ) ;
75+
6776 this . onComplete = GetObjectValue ( config , 'onComplete' , false ) ;
68- this . onStop = GetObjectValue ( config , 'onStop ' , false ) ;
77+ this . onCompleteParams = GetObjectValue ( config , 'onCompleteParams ' , [ ] ) ;
6978} ;
7079
7180Animation . prototype . constructor = Animation ;
@@ -92,6 +101,8 @@ Animation.prototype = {
92101 component . _repeat = this . repeat ;
93102 component . _repeatDelay = this . repeatDelay ;
94103 component . _yoyo = this . yoyo ;
104+ component . _callbackArgs [ 1 ] = this ;
105+ component . _updateParams = component . _callbackArgs . concat ( this . onUpdateParams ) ;
95106 }
96107
97108 component . updateFrame ( this . frames [ startFrame ] ) ;
@@ -209,21 +220,21 @@ Animation.prototype = {
209220
210221 component . pendingRepeat = false ;
211222
212- // OnRepeat
223+ if ( this . onRepeat )
224+ {
225+ this . onRepeat . apply ( this . callbackScope , component . _callbackArgs . concat ( this . onRepeatParams ) ) ;
226+ }
213227 }
214228 } ,
215229
216230 completeAnimation : function ( component )
217231 {
218- component . stop ( ) ;
219-
220232 if ( this . hideOnComplete )
221233 {
222234 component . parent . visible = false ;
223235 }
224236
225- // Events
226-
237+ component . stop ( true ) ;
227238 } ,
228239
229240 setFrame : function ( component )
0 commit comments