@@ -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
@@ -1068,7 +1073,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
1068
1073
*/
1069
1074
startWithTarget :function ( target ) {
1070
1075
cc . ActionInterval . prototype . startWithTarget . call ( this , target ) ;
1071
- this . _startPosition = target . getPosition ( ) ;
1076
+ this . _previousPosition = this . _startPosition = target . getPosition ( ) ;
1072
1077
} ,
1073
1078
1074
1079
/**
@@ -1079,8 +1084,16 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
1079
1084
var frac = time * this . _jumps % 1.0 ;
1080
1085
var y = this . _height * 4 * frac * ( 1 - frac ) ;
1081
1086
y += this . _delta . y * time ;
1087
+
1082
1088
var x = this . _delta . x * time ;
1083
- this . _target . setPosition ( cc . p ( this . _startPosition . x + x , this . _startPosition . y + y ) ) ;
1089
+
1090
+ var currentPos = this . _target . getPosition ( ) ;
1091
+
1092
+ var diff = cc . pSub ( currentPos , this . _previousPosition ) ;
1093
+ this . _startPosition = cc . pAdd ( diff , this . _startPosition ) ;
1094
+ var newPos = cc . pAdd ( this . _startPosition , cc . p ( x , y ) ) ;
1095
+ this . _target . setPosition ( newPos ) ;
1096
+ this . _previousPosition = newPos ;
1084
1097
}
1085
1098
} ,
1086
1099
0 commit comments