赞
踩
- </pre><pre code_snippet_id="1722660" snippet_file_name="blog_20160620_2_7592120" name="code" class="html">1.定时器
- //创建计时器对象,两个属性分别是delay与repeatCount,表示每次间隔的时间(以毫秒为单位)和执行的次数(如果次数为0,则表示不停的执行).
- var timer:egret.Timer=new egret.Timer(500,5);
- //注册事件监听
- timer.addEventListener(egret.TimerEvent.TIMER,this.timerFunc,this); //计时
- timer.addEventListener(egret.TimerEvent.TIME_COMPLETE,this.timerComFunc,this); //计时结束
- //开始计时
- timer.start();
- <pre name="code" class="html">private timerFunc()
- {
- console.log("计时");
- }
- private timerComFunc()
- {
- <span style="white-space:pre"> </span>console.log("计时结束"); }
- }
如果要继续使用计时器,记得this.timer.reset()
</pre><pre code_snippet_id="1722660" snippet_file_name="blog_20160620_6_8956106" name="code" class="html">
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。