Laya 实操五:定时器

定时器

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);//距离上一帧时间
    }
}

 

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值