@@ -121,6 +121,7 @@ ccs.ActionTimeline = cc.Action.extend({
121121 _loop : null ,
122122 _frameEventListener : null ,
123123 _animationInfos : null ,
124+ _lastFrameListener : null ,
124125
125126 ctor : function ( ) {
126127 cc . Action . prototype . ctor . call ( this ) ;
@@ -399,15 +400,24 @@ ccs.ActionTimeline = cc.Action.extend({
399400 }
400401
401402 this . _time += delta * this . _timeSpeed ;
402- this . _currentFrame = this . _time / this . _frameInternal | 0 ;
403+ var endoffset = this . _time - this . _endFrame * this . _frameInternal ;
403404
404- this . _stepToFrame ( this . _currentFrame ) ;
405-
406- if ( this . _time > this . _endFrame * this . _frameInternal ) {
405+ if ( endoffset < this . _frameInternal ) {
406+ this . _currentFrame = this . _time / this . _frameInternal ;
407+ this . _stepToFrame ( this . _currentFrame ) ;
408+ if ( endoffset >= 0 && this . _lastFrameListener )
409+ this . _lastFrameListener ( ) ;
410+ } else {
407411 this . _playing = this . _loop ;
408- if ( ! this . _playing )
412+ if ( ! this . _playing ) {
409413 this . _time = this . _endFrame * this . _frameInternal ;
410- else
414+ if ( this . _currentFrame != this . _endFrame ) {
415+ this . _currentFrame = this . _endFrame ;
416+ this . _stepToFrame ( this . _currentFrame ) ;
417+ if ( this . _lastFrameListener )
418+ this . _lastFrameListener ( ) ;
419+ }
420+ } else
411421 this . gotoFrameAndPlay ( this . _startFrame , this . _endFrame , this . _loop ) ;
412422 }
413423
@@ -492,6 +502,14 @@ ccs.ActionTimeline = cc.Action.extend({
492502
493503 getAnimationInfo : function ( name ) {
494504 return this . _animationInfos [ name ] ;
505+ } ,
506+
507+ setLastFrameCallFunc : function ( listener ) {
508+ this . _lastFrameListener = listener ;
509+ } ,
510+
511+ clearLastFrameCallFunc : function ( ) {
512+ this . _lastFrameListener = null ;
495513 }
496514} ) ;
497515
0 commit comments