定时器
export default class Test extends Laya.Script {
constructor() { super(); }
onStart(){
//n帧后运行一次
//Laya.timer.frameOnce(300,this,function(){console.log("ok");});
//每隔n帧,循环运行
//Laya.timer.frameLoop(300,this,function(){console.log("ok");});
//n毫秒后运行一次
//Laya.timer.once(1000,this,function(){console.log("ok");});
//每隔n毫秒,循环运行
//Laya.timer.loop(1000,this,function(){console.log("ok");});
//let func = function(){console.log("ok");}
//Laya.timer.loop(2000,this,func);
//取消一个定时器
//Laya.timer.once(10000,this,()=>{Laya.timer.clear(this,func)});
//取消所有定时器
//Laya.timer.once(10000,this,()=>{Laya.timer.clearAll(this)});
//下一帧执行
//Laya.timer.callLater(this,function(){console.log("ok");});
//let func = function(){console.log("ok");}
//Laya.timer.loop(1000,this,func);
//立即执行一次,并取消此定时器
//Laya.timer.once(2000,this,function(){Laya.timer.runTimer(this,func)});
//含参
//let func = function(p1,p2,p3){console.log(p1,p2,p3);}
//Laya.timer.once(3000,this,func,[24,true,"aaa"]);
//Laya.timer.scale = 1;//时间缩放
}
onUpdate(){
//console.log(Laya.timer.currFrame);//当前帧数
//console.log(Laya.timer.currTimer);//当前帧开始的时间戳
//console.log(Laya.timer.delta);//距离上一帧时间
}
}