Class Tick
Provides a centralized tick or heartbeat. Listeners can subscribe to the tick, and identify whether they are pausable or not.
Defined in: Tick.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Tick()
The Tick class uses a static interface (ex.
|
Field Attributes | Field Name and Description |
---|---|
<private> <static> |
Tick._inited
|
<private> <static> |
Tick._interval
|
<private> <static> |
Tick._intervalID
|
<private> <static> |
Tick._lastTime
|
<private> <static> |
Tick._listeners
|
<private> <static> |
Tick._pauseable
|
<private> <static> |
Tick._paused
|
<private> <static> |
Tick._pausedTicks
|
<private> <static> |
Tick._pausedTime
|
<private> <static> |
Tick._startTime
|
<private> <static> |
Tick._ticks
|
Method Attributes | Method Name and Description |
---|---|
<private> <static> |
Tick._getTime()
|
<private> <static> |
Tick._tick()
|
<static> |
Tick.addListener(o, pausable)
Adds a listener to the tick.
|
<static> |
Tick.getFPS()
Returns the frame rate in frames per second (FPS).
|
<static> |
Tick.getInterval()
Returns the current time between ticks, as set with setInterval.
|
<static> |
Tick.getPaused()
Returns a boolean indicating whether Tick is currently paused, as set with setPaused.
|
<static> |
Tick.getTicks(pauseable)
Returns the number of ticks that have elapsed while Tick was active.
|
<static> |
Tick.getTime(pauseable)
Returns the number of milliseconds that have elapsed since Tick was loaded.
|
<static> |
Tick.removeAllListeners()
Removes all listeners.
|
<static> |
Tick.removeListener(o)
Removes the specified listener.
|
<static> |
Tick.setInterval(interval)
Sets the time (in milliseconds) between ticks.
|
<static> |
Tick.setPaused(value)
While Tick is paused, pausable listeners are not ticked.
|
Class Detail
Tick()
The Tick class uses a static interface (ex. Tick.getPaused()) and should not be instantiated.
Field Detail
<private> <static>
Tick._inited
<private> <static>
Tick._interval
<private> <static>
Tick._intervalID
<private> <static>
Tick._lastTime
<private> <static>
Tick._listeners
<private> <static>
Tick._pauseable
<private> <static>
Tick._paused
<private> <static>
Tick._pausedTicks
<private> <static>
Tick._pausedTime
<private> <static>
Tick._startTime
<private> <static>
Tick._ticks
Method Detail
<private> <static>
Tick._getTime()
<private> <static>
Tick._tick()
<static>
Tick.addListener(o, pausable)
Adds a listener to the tick. The listener object must expose a .tick() method, which will be called once each tick. The exposed tick method can optionally accept a single parameter, which will include the elapsed time between the previous tick and the current one.
- Parameters:
- o
- The object to add as a listener.
- pausable
- If false, the listener will continue to have tick called even when Tick is paused via Tick.pause(). Default is false.
<static>
Tick.getFPS()
Returns the frame rate in frames per second (FPS). For example, with an interval of 40, getFPS() will return 25 (1000ms per second divided by 40 ms per tick = 25fps).
<static>
Tick.getInterval()
Returns the current time between ticks, as set with setInterval.
<static>
Tick.getPaused()
Returns a boolean indicating whether Tick is currently paused, as set with setPaused.
<static>
Tick.getTicks(pauseable)
Returns the number of ticks that have elapsed while Tick was active.
- Parameters:
- pauseable
- Indicates whether to return the elapsed ticks for pauseable, or unpauseable listeners.
<static>
Tick.getTime(pauseable)
Returns the number of milliseconds that have elapsed since Tick was loaded. For example, you could use this in a time synchronized animation to determine the exact amount of time that has elapsed.
- Parameters:
- pauseable
- Indicates whether to return the elapsed time for pauseable, or unpauseable listeners. If true, time that elapsed while Tick was paused is not included.
<static>
Tick.removeAllListeners()
Removes all listeners.
<static>
Tick.removeListener(o)
Removes the specified listener.
- Parameters:
- o
- The listener to remove.
<static>
Tick.setInterval(interval)
Sets the time (in milliseconds) between ticks. Default is 50 (20 FPS).
- Parameters:
- interval
- Time in milliseconds between ticks.
<static>
Tick.setPaused(value)
While Tick is paused, pausable listeners are not ticked. See addListener for more information.
- Parameters:
- value
- Indicates whether to pause (true) or unpause (false) Tick.