HTML5游戏制作之路_09_egret的Timer

来源:互联网 发布:centos 防火墙配置文件 编辑:程序博客网 时间:2024/06/06 21:40

/*

使用的版本为2.5

*/

Timer为计时器。

/***   以下示例使用 Timer 创建计时器,并侦听egret.TimerEvent.TIMER与egret.TimerEvent.TIMER_COMPLETE事件。*/class TimerExample extends egret.DisplayObjectContainer {    public constructor() {        super();<span style="white-space:pre"></span>//每隔1s记一次时间,共五次        var timer: egret.Timer = new egret.Timer(1000, 5);<span style="white-space:pre"></span>//每次计时调用        timer.addEventListener(egret.TimerEvent.TIMER, this.timerFunc, this);
<span style="white-space:pre"></span>//计时结束        timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.timerComFunc, this);        timer.start();    }    private timerFunc(event:egret.TimerEvent) {        console.log("timerFunc count" + (<egret.Timer>event.target).currentCount);        //timerFunc count1        //timerFunc count2        //timerFunc count3        //timerFunc count4        //timerFunc count5    }    private timerComFunc(event: egret.TimerEvent) {        console.log("timerComFunc count" + (<egret.Timer>event.target).currentCount);        ////timerFunc count5    }}


0 0
原创粉丝点击