Timer

author:
Timothy John
description:
A timer that works exactly like flash.utils.Timer, but uses Starling's lighter-weight Juggler, DelayedCall and EventDispatcher.
compatible:
v2.1
tag:
Timer, Juggler, DelayedCall, Animation
homepage:
https://gist.github.com/esidegallery/c5312f74bee283134159aa206ce11bcd

Overview

Behaves exactly like flash.utils.Timer, though is more lightweight and is more accurate when the delay is set to very small numbers.

The only difference in implementation is that there isn't an associated TimerEvent; it dispatches a standard Starling Event and its event strings are members of its class.

It has been tested alongside flash.utils.Timer under different scenarios (such as changing its values while it is running) and the results are the same.

import starling.extensions.timer.Timer;
var starlingTimer:Timer = new Timer(250, 5);
starlingTimer.addEventListener(Timer.TIMER, starlingTimerHandler);
starlingTimer.addEventListener(Timer.TIMER_COMPLETE, starlingTimerCompleteHandler);
starlingTimer.start();

Changelog

  • 2016/11/17 11:56: First public version

Source Code

User Comments

Feel free to edit this part of the page if you want to add information that's lacking in the above description.
Questions are better asked in the forum, though.

  extensions/timer.txt · Last modified: 2016/11/17 12:15 by timwjohn
 
Powered by DokuWiki