clearInterval 无效

cocos creator 1.6.2 setInterval 正常

调用 clearInterval 有些timer可以清理掉 有些清理不掉

在 jsb_polyfill.js 的

window.clearInterval = function(intervalId) {
var target = _windowTimeFunHash[intervalId];
if (target) {
console.log(“clearInterval find id:”+intervalId);
cc.director.getScheduler().unschedule(target.fun, target);
delete _windowTimeFunHash[intervalId];
}
};

加了打印 intervalId 是对的 也查找到了 但是unschedule 之后 timer扔正常运行

没人遇到吗?

我也遇到了

我的也是

我自己把它重写了 哈哈

大家请注意下 Interval的写法:
var test = setInterval(function () {
clearInterval(test);
}, 1000);
这种写法是无效的,timer无法清理掉:

下面这种写法才能正确清理timer
var clear = function (interval) {
clearInterval(interval);
}
var test = setInterval(function () {
clear(test);
}, 1000);