Skip to content

739 stackable actions #744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions cocos2d/actions/CCActionInterval.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ cc.MoveTo = cc.ActionInterval.extend(/** @lends cc.MoveTo# */{
*/
startWithTarget:function (target) {
cc.ActionInterval.prototype.startWithTarget.call(this, target);
this._startPosition = target.getPosition();
this._previousPosition = this._startPosition = target.getPosition();
this._delta = cc.pSub(this._endPosition, this._startPosition);
},

Expand All @@ -789,8 +789,13 @@ cc.MoveTo = cc.ActionInterval.extend(/** @lends cc.MoveTo# */{
*/
update:function (time) {
if (this._target) {
this._target.setPosition(cc.p(this._startPosition.x + this._delta.x * time,
this._startPosition.y + this._delta.y * time));
var currentPos = this._target.getPosition();
var diff = cc.pSub(currentPos, this._previousPosition);
this._startPosition = cc.pAdd(this._startPosition, diff);
var newPos = cc.p(this._startPosition.x + this._delta.x * time,
this._startPosition.y + this._delta.y * time);
this._target.setPosition(newPos);
this._previousPosition = newPos;
}
},

Expand Down Expand Up @@ -1068,7 +1073,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
*/
startWithTarget:function (target) {
cc.ActionInterval.prototype.startWithTarget.call(this, target);
this._startPosition = target.getPosition();
this._previousPosition = this._startPosition = target.getPosition();
},

/**
Expand All @@ -1079,8 +1084,16 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
var frac = time * this._jumps % 1.0;
var y = this._height * 4 * frac * (1 - frac);
y += this._delta.y * time;

var x = this._delta.x * time;
this._target.setPosition(cc.p(this._startPosition.x + x, this._startPosition.y + y));

var currentPos = this._target.getPosition();

var diff = cc.pSub(currentPos, this._previousPosition);
this._startPosition = cc.pAdd(diff, this._startPosition);
var newPos = cc.pAdd(this._startPosition, cc.p(x, y));
this._target.setPosition(newPos);
this._previousPosition = newPos;
}
},

Expand Down
1 change: 0 additions & 1 deletion cocos2d/actions/CCActionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ cc.ActionManager = cc.Class.extend({
}
//creates a array for that eleemnt to hold the actions
this._actionAllocWithHashElement(element);
cc.Assert((element.actions.indexOf(action) == -1), "ActionManager.addAction(),");

element.actions.push(action);
action.startWithTarget(target);
Expand Down