函数外为什么停不了?clearInterval

cs113dn cs113dn 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
private countDownTimer = 0;
private timeControl(second) {
if (second > 0) {
this.countDownTimer = egret.setTimeout(()=>{

}, this, 1000);

this.countDownTimer = egret.setInterval(function () {
if (second > 0 && this.bCanSelectFreeGame) {
second--;
// console.log('secound:', second);
let str: string = Utils.replaceString(Config.language['freeGameCountDown_' + Config.lang], [second]);
MainGameView.instance.changeGameTip(str);

if (second <= 0) {
// console.log("停止计时");
clearInterval(this.countDownTimer);//倒计时结束停止有效

let str: string = Utils.replaceString(Config.language['mainGame016_' + Config.lang]);
MainGameView.instance.changeGameTip(str);
}
}
}, this, 1000);
}
}



private onOpenButton(evt: egret.Event) {
let self = this;

clearInterval(this.countDownTimer);//倒计时还未结束时点击按钮停止无效?
}
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
cs113dn
JavaScript 87,983 成员 224,681 内容