Skip to content

Commit fe08133

Browse files
Actions copy() fixes.
There was an infity recursion if you copy a CallFunc. Apparently cc.clone() was not handling an specially case. I also added an explicity copy for sequence, since I think it is going to be faster.
1 parent 6748f2c commit fe08133

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cocos2d/actions/CCActionInstant.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
326326
this._selectorTarget = sel;
327327
}
328328
},
329+
330+
copy:function() {
331+
var n = new cc.CallFunc();
332+
n.initWithTarget( this._selectorTarget, this._callFunc, this._data );
333+
return n;
334+
},
329335
_selectorTarget:null,
330336
_callFunc:null
331337
});

cocos2d/actions/CCActionInterval.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,15 @@ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{
242242
*/
243243
reverse:function () {
244244
return cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse());
245-
}
245+
},
246+
247+
/**
248+
* to copy object with deep copy.
249+
* @return {object}
250+
*/
251+
copy:function () {
252+
return cc.Sequence._actionOneTwo(this._actions[0].copy(), this._actions[1].copy() );
253+
},
246254
});
247255
/** helper constructor to create an array of sequenceable actions
248256
* @param {Array|cc.FiniteTimeAction} tempArray

0 commit comments

Comments
 (0)