Skip to content

Commit 48b08f6

Browse files
committed
Fix cc.CallFunc issue with parameters
1 parent e239343 commit 48b08f6

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

cocos2d/actions/CCActionInstant.js

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,10 @@ cc.Place.create = cc.place;
630630
*/
631631
cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
632632
_selectorTarget:null,
633-
_callFunc:null,
634633
_function:null,
635634
_data:null,
636635

637-
/**
636+
/**
638637
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
639638
* Creates a CallFunc action with the callback.
640639
* @param {function} selector
@@ -644,11 +643,7 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
644643
ctor:function(selector, selectorTarget, data){
645644
cc.FiniteTimeAction.prototype.ctor.call(this);
646645

647-
if(selector !== undefined){
648-
if(selectorTarget === undefined)
649-
this.initWithFunction(selector);
650-
else this.initWithFunction(selector, selectorTarget, data);
651-
}
646+
this.initWithFunction(selector, selectorTarget, data);
652647
},
653648

654649
/**
@@ -659,24 +654,25 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
659654
* @return {Boolean}
660655
*/
661656
initWithFunction:function (selector, selectorTarget, data) {
662-
if (selectorTarget) {
663-
this._data = data;
664-
this._callFunc = selector;
657+
if (selector) {
658+
this._function = selector;
659+
}
660+
if (selectorTarget) {
665661
this._selectorTarget = selectorTarget;
666-
}
667-
else if (selector)
668-
this._function = selector;
662+
}
663+
if (data) {
664+
this._data = data;
665+
}
669666
return true;
670667
},
671668

672669
/**
673670
* execute the function.
674671
*/
675672
execute:function () {
676-
if (this._callFunc != null) //CallFunc, N, ND
677-
this._callFunc.call(this._selectorTarget, this.target, this._data);
678-
else if(this._function)
679-
this._function.call(null, this.target);
673+
if (this._function) {
674+
this._function.call(this._selectorTarget, this.target, this._data);
675+
}
680676
},
681677

682678
/**
@@ -715,12 +711,8 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
715711
* @return {cc.CallFunc}
716712
*/
717713
clone:function(){
718-
var action = new cc.CallFunc();
719-
if(this._selectorTarget){
720-
action.initWithFunction(this._callFunc, this._selectorTarget, this._data)
721-
}else if(this._function){
722-
action.initWithFunction(this._function);
723-
}
714+
var action = new cc.CallFunc();
715+
action.initWithFunction(this._function, this._selectorTarget, this._data);
724716
return action;
725717
}
726718
});

0 commit comments

Comments
 (0)