pixi-timeout
Pixi-timeout is a plugin which replicates the behaviour of window.setTimout but uses PIXI.Ticker (requestAnimationFrame) as the method for progressing time. The bonus is that any timeouts will be paused and resumed automatically when you call PIXI.Application.stop
& PIXI.Application.start
Install
npm i pixi-timeout
Usage
Importing
common.js
es6 modules
Basic usage.
Simply supply the time to wait in seconds and the function to call upon completion
PIXI
Clear
There are 2 ways to clear a timeout. First the traditional way
const timer = PIXIPIXI
or more conviniently
const timer = PIXItimerclear
Finish
You can finish a timer immediately, which will simply cancel the timer and fire the callback.
timer
Pause & Resume
If you are using PIXI.Application for instantiation then all current timers are automatically paused and resumed when PIXI.Application.stop
& PIXI.Application.start
are called. Which is great for keeping audio, tweens and timeouts synchronised.
const myApp = myApp // pausemyAppstart //resume
FPS, Speed & Time
pixi-timeout calculates time based on the PIXI.ticker settings. It assumes 60fps is the desired rate and uses the deltaTime
value from last frame to this frame to determine the correct time progression. Additionally it uses the speed
value from the PIXI.ticker
, so if you wish to adjust the optimal fps you can do so by changing the PIXI.ticker value and pixi-timeout will adjust accordingly