File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -780,7 +780,7 @@ cc.MoveTo = cc.ActionInterval.extend(/** @lends cc.MoveTo# */{
780
780
*/
781
781
startWithTarget :function ( target ) {
782
782
cc . ActionInterval . prototype . startWithTarget . call ( this , target ) ;
783
- this . _startPosition = target . getPosition ( ) ;
783
+ this . _previousPosition = this . _startPosition = target . getPosition ( ) ;
784
784
this . _delta = cc . pSub ( this . _endPosition , this . _startPosition ) ;
785
785
} ,
786
786
@@ -789,8 +789,13 @@ cc.MoveTo = cc.ActionInterval.extend(/** @lends cc.MoveTo# */{
789
789
*/
790
790
update :function ( time ) {
791
791
if ( this . _target ) {
792
- this . _target . setPosition ( cc . p ( this . _startPosition . x + this . _delta . x * time ,
793
- this . _startPosition . y + this . _delta . y * time ) ) ;
792
+ var currentPos = this . _target . getPosition ( ) ;
793
+ var diff = cc . pSub ( currentPos , this . _previousPosition ) ;
794
+ this . _startPosition = cc . pAdd ( this . _startPosition , diff ) ;
795
+ var newPos = cc . p ( this . _startPosition . x + this . _delta . x * time ,
796
+ this . _startPosition . y + this . _delta . y * time ) ;
797
+ this . _target . setPosition ( newPos ) ;
798
+ this . _previousPosition = newPos ;
794
799
}
795
800
} ,
796
801
You can’t perform that action at this time.
0 commit comments