//定时器demo
module game{
export class TimerDemo extends egret.DisplayObjectContainer{
private count : number = 0;
public constructor(){
super();
var timer:egret.Timer = new egret.Timer(1000,5);
timer.addEventListener(egret.TimerEvent.TIMER,this.timerFunc,this);
timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE,this.timerComFunc,this);
timer.start();
}
private timerFunc(): void{
this.count += 1;
console.log("计时: " + this.count);
}
private timerComFunc(){
console.log("计时结束");
}
}
}
本文介绍了一个使用Egret框架实现的定时器示例,演示了如何创建一个每秒触发并计数的定时器,以及在指定次数后触发完成事件的方法。
367

被折叠的 条评论
为什么被折叠?



