btnRules: function () {
var interval=this.random(2,5);
// 开始延时
var delay = 2;
this.schedule(function(){
interval= this.random(2,5);
cc.log(interval);
}, interval, 10, delay);
this.rule.active = true;
}, 请问这样可以实现动态的间隔时间吗
用scheduleOnce吧
最好不要用计时器,计时坑.用update的函数
update: function () {
if (!cc.isValid(this.node)) return;
var nt = new Date().getTime();
if (!this.lastTickTime) this.lastTickTime = nt;
if(this.times == parseInt((nt - this.lastTickTime)/1000)) return
this.times = parseInt((nt - this.lastTickTime)/1000)
}, 你输出一下 console.(this.time) 在加上你的要实现的内容节点属性
上传中…
计时器有什么坑?
哦哦好的谢谢大神
我试试 谢谢大神回复