Skip to content

Commit 5b826da

Browse files
committed
setInterval and setTimeout supports arguments
1 parent 9c9308a commit 5b826da

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

frameworks/js-bindings/bindings/script/jsb_cocos2d.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ var WindowTimeFun = cc.Class.extend({
651651
Function(code)();
652652
}
653653
else if (typeof code == "function") {
654-
code();
654+
code.apply(null, this._args);
655655
}
656656
}
657657
});
@@ -664,6 +664,8 @@ var WindowTimeFun = cc.Class.extend({
664664
*/
665665
var setTimeout = function (code, delay) {
666666
var target = new WindowTimeFun(code);
667+
if (arguments.length > 2)
668+
target._args = Array.prototype.slice.call(arguments, 2);
667669
cc.Director.getInstance().getScheduler().scheduleCallbackForTarget(target, target.fun, delay / 1000, 0, 0, false);
668670
_windowTimeFunHash[target._intervalId] = target;
669671
return target._intervalId;
@@ -677,6 +679,8 @@ var setTimeout = function (code, delay) {
677679
*/
678680
var setInterval = function (code, delay) {
679681
var target = new WindowTimeFun(code);
682+
if (arguments.length > 2)
683+
target._args = Array.prototype.slice.call(arguments, 2);
680684
cc.Director.getInstance().getScheduler().scheduleCallbackForTarget(target, target.fun, delay / 1000, cc.REPEAT_FOREVER, 0, false);
681685
_windowTimeFunHash[target._intervalId] = target;
682686
return target._intervalId;

0 commit comments

Comments
 (0)