PIXI.Ticker
class Ticker
A Ticker class that runs an update loop that other objects listen to.
This class is composed around listeners meant for execution on the next requested animation frame. Animation frames are requested only when necessary, e.g. When the ticker is started and the emitter has listeners.
Summary
Properties from Ticker
PIXI.Ticker |
|
PIXI.Ticker |
|
boolean |
|
number |
|
number |
|
number |
|
number |
|
number |
|
number |
|
number |
|
number |
|
number |
|
boolean |
|
Methods from Ticker
this |
|
this |
|
void |
Destroy the ticker and don't use after this. Calling this method removes all references to internal events. |
this |
|
void |
Starts the ticker. If the ticker has listeners a new animation frame is requested at this point. |
void |
Stops the ticker. If the ticker has requested an animation frame it is canceled at this point. |
void |
|
Public Properties
static system: PIXI.Ticker
The system ticker instance used by PIXI.InteractionManager and by
PIXI.BasePrepare for core timing functionality that shouldn't usually need to be paused,
unlike the shared
ticker which drives visual animations and rendering which may want to be paused.
The property PIXI.Ticker#autoStart is set to true
for this instance.
autoStart: boolean = false
Whether or not this ticker should invoke the method PIXI.Ticker#start automatically when a listener is added.
count: number
The number of listeners on this ticker, calculated by walking through linked list
deltaMS: number = 16.66
Scaler time elapsed in milliseconds from last frame to this frame. This value is capped by setting PIXI.Ticker#minFPS and is scaled with PIXI.Ticker#speed. Note: The cap may be exceeded by scaling. If the platform supports DOMHighResTimeStamp, this value will have a precision of 1 µs. Defaults to target frame time
deltaTime: number = 1
Scalar time value from last frame to this frame. This value is capped by setting PIXI.Ticker#minFPS and is scaled with PIXI.Ticker#speed. Note: The cap may be exceeded by scaling.
elapsedMS: number = 16.66
Time elapsed in milliseconds from last frame to this frame. Opposed to what the scalar PIXI.Ticker#deltaTime is based, this value is neither capped nor scaled. If the platform supports DOMHighResTimeStamp, this value will have a precision of 1 µs. Defaults to target frame time
FPS: number
The frames per second at which this ticker is running. The default is approximately 60 in most modern browsers. Note: This does not factor in the value of PIXI.Ticker#speed, which is specific to scaling PIXI.Ticker#deltaTime.
lastTime: number = -1
The last time PIXI.Ticker#update was invoked. This value is also reset internally outside of invoking update, but only when a new animation frame is requested. If the platform supports DOMHighResTimeStamp, this value will have a precision of 1 µs.
maxFPS: number = 0
Manages the minimum amount of milliseconds required to
elapse between invoking PIXI.Ticker#update.
This will effect the measured value of PIXI.Ticker#FPS.
If it is set to 0
, then there is no limit; PixiJS will render as many frames as it can.
Otherwise it will be at least minFPS
minFPS: number = 10
Manages the maximum amount of milliseconds allowed to
elapse between invoking PIXI.Ticker#update.
This value is used to cap PIXI.Ticker#deltaTime,
but does not effect the measured value of PIXI.Ticker#FPS.
When setting this property it is clamped to a value between
0
and PIXI.settings.TARGET_FPMS * 1000
.
speed: number = 1
Factor of current PIXI.Ticker#deltaTime.
// Scales ticker.deltaTime to what would be
// the equivalent of approximately 120 FPS
ticker.speed = 2;
started: boolean = false
Whether or not this ticker has been started.
true
if PIXI.Ticker#start has been called.
false
if PIXI.Ticker#stop has been called.
While false
, this value may change to true
in the
event of PIXI.Ticker#autoStart being true
and a listener is added.
Public Methods
add(fn: TickerCallback<T>, context: T, priority: number) → {this}
Register a handler for tick events. Calls continuously unless it is removed or the ticker is stopped.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fn | TickerCallback<T> |
The listener function to be added for updates |
||
context | T |
<optional> |
The listener context |
|
priority | number |
<optional> |
PIXI.UPDATE_PRIORITY.NORMAL |
The priority for emitting |
Type | Description |
---|---|
this |
This instance of a ticker |
addOnce(fn: TickerCallback<T>, context: T, priority: number) → {this}
Add a handler for the tick event which is only execute once.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fn | TickerCallback<T> |
The listener function to be added for one update |
||
context | T |
<optional> |
The listener context |
|
priority | number |
<optional> |
PIXI.UPDATE_PRIORITY.NORMAL |
The priority for emitting |
Type | Description |
---|---|
this |
This instance of a ticker |
destroy() → {void}
Destroy the ticker and don't use after this. Calling this method removes all references to internal events.
Type | Description |
---|---|
void |
remove(fn: TickerCallback<T>, context: T) → {this}
Removes any handlers matching the function and context parameters. If no handlers are left after removing, then it cancels the animation frame.
Name | Type | Attributes | Description |
---|---|---|---|
fn | TickerCallback<T> |
The listener function to be removed |
|
context | T |
<optional> |
The listener context to be removed |
Type | Description |
---|---|
this |
This instance of a ticker |
start() → {void}
Starts the ticker. If the ticker has listeners a new animation frame is requested at this point.
Type | Description |
---|---|
void |
stop() → {void}
Stops the ticker. If the ticker has requested an animation frame it is canceled at this point.
Type | Description |
---|---|
void |
update(currentTime: number) → {void}
Triggers an update. An update entails setting the current PIXI.Ticker#elapsedMS, the current PIXI.Ticker#deltaTime, invoking all listeners with current deltaTime, and then finally setting PIXI.Ticker#lastTime with the value of currentTime that was provided. This method will be called automatically by animation frame callbacks if the ticker instance has been started and listeners are added.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
currentTime | number |
<optional> |
performance.now() |
the current time of execution |
Type | Description |
---|---|
void |