@@ -146,6 +146,9 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
146
146
startWithTarget :function ( target ) {
147
147
this . _super ( target ) ;
148
148
this . _deltaT = 1 / this . _points . length ;
149
+
150
+ this . _previousPosition = this . _target . getPosition ( ) ;
151
+ this . _accumulatedDiff = cc . p ( 0 , 0 ) ;
149
152
} ,
150
153
151
154
/**
@@ -169,6 +172,14 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
169
172
cc . getControlPointAt ( this . _points , p + 1 ) ,
170
173
cc . getControlPointAt ( this . _points , p + 2 ) ,
171
174
this . _tension , lt ) ;
175
+
176
+ var node = this . _target ;
177
+ var diff = cc . pSub ( node . getPosition ( ) , this . _previousPosition ) ;
178
+ if ( diff . x != 0 || diff . y != 0 ) {
179
+ this . _accumulatedDiff = cc . pAdd ( this . _accumulatedDiff , diff ) ;
180
+ newPos = cc . pAdd ( newPos , this . _accumulatedDiff ) ;
181
+ }
182
+
172
183
this . updatePosition ( newPos ) ;
173
184
} ,
174
185
@@ -187,6 +198,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend(/** @lends cc.CardinalSplineTo# *
187
198
*/
188
199
updatePosition :function ( newPos ) {
189
200
this . _target . setPosition ( newPos ) ;
201
+ this . _previousPosition = newPos ;
190
202
} ,
191
203
192
204
/**
@@ -295,7 +307,9 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend(/** @lends cc.CardinalSplineBy#
295
307
* @param {cc.Point } newPos
296
308
*/
297
309
updatePosition :function ( newPos ) {
298
- this . _target . setPosition ( cc . pAdd ( newPos , this . _startPosition ) ) ;
310
+ var p = cc . pAdd ( newPos , this . _startPosition ) ;
311
+ this . _target . setPosition ( p )
312
+ this . _previousPosition = p ;
299
313
}
300
314
} ) ;
301
315
0 commit comments