Skip to content

Commit 8cd425c

Browse files
committed
Issue cocos2d#739: Updating JumpBy with stackable actions.
1 parent 3796062 commit 8cd425c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cocos2d/actions/CCActionInterval.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
10731073
*/
10741074
startWithTarget:function (target) {
10751075
cc.ActionInterval.prototype.startWithTarget.call(this, target);
1076-
this._startPosition = target.getPosition();
1076+
this._previousPosition = this._startPosition = target.getPosition();
10771077
},
10781078

10791079
/**
@@ -1084,8 +1084,16 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
10841084
var frac = time * this._jumps % 1.0;
10851085
var y = this._height * 4 * frac * (1 - frac);
10861086
y += this._delta.y * time;
1087+
10871088
var x = this._delta.x * time;
1088-
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;
10891097
}
10901098
},
10911099

cocos2d/actions/CCActionManager.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ cc.ActionManager = cc.Class.extend({
9898
}
9999
//creates a array for that eleemnt to hold the actions
100100
this._actionAllocWithHashElement(element);
101-
cc.Assert((element.actions.indexOf(action) == -1), "ActionManager.addAction(),");
102101

103102
element.actions.push(action);
104103
action.startWithTarget(target);

0 commit comments

Comments
 (0)