当前位置:   article > 正文

Egret 自定义计时器_egret中如何写一个计时器

egret中如何写一个计时器
  1. </pre><pre code_snippet_id="1722660" snippet_file_name="blog_20160620_2_7592120" name="code" class="html">1.定时器
  2. //创建计时器对象,两个属性分别是delay与repeatCount,表示每次间隔的时间(以毫秒为单位)和执行的次数(如果次数为0,则表示不停的执行).
  3. var timer:egret.Timer=new egret.Timer(500,5);
  4. //注册事件监听
  5. timer.addEventListener(egret.TimerEvent.TIMER,this.timerFunc,this); //计时
  6. timer.addEventListener(egret.TimerEvent.TIME_COMPLETE,this.timerComFunc,this); //计时结束
  7. //开始计时
  8. timer.start();
  1. <pre name="code" class="html">private timerFunc()
  2. {
  3. console.log("计时");
  4. }
  5. private timerComFunc()
  6. {  
  1. <span style="white-space:pre"> </span>console.log("计时结束"); }
  2. }
如果要继续使用计时器,记得this.timer.reset()

</pre><pre code_snippet_id="1722660" snippet_file_name="blog_20160620_6_8956106" name="code" class="html">
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/54434?site
推荐阅读
相关标签
  

闽ICP备14008679号