Namespace: ticker

Tiny. ticker

This namespace contains an API for interacting with Tiny's internal global update loop.

This ticker is used for rendering, AnimatedSprite,
InteractionManager and many other time-based Tiny systems.

Example

const ticker = new Tiny.ticker.Ticker();
ticker.stop();
ticker.add((deltaTime) => {
  // do something every frame
});
ticker.start();

Classes

CountDown
Ticker

Members

static,constantTiny.ticker.sharedTiny.ticker.Ticker

The shared ticker instance used by Tiny.AnimatedSprite and by Tiny.interaction.InteractionManager.
The property Tiny.ticker.Ticker#autoStart is set to true for this instance. Please follow the examples for usage, including how to opt-out of auto-starting the shared ticker.

Examples
let ticker = Tiny.ticker.shared;
// Set this to prevent starting this ticker when listeners are added.
// By default this is true only for the Tiny.ticker.shared instance.
ticker.autoStart = false;
// FYI, call this to ensure the ticker is stopped. It should be stopped
// if you have not attempted to render anything yet.
ticker.stop();
// Call this when you are ready for a running shared ticker.
ticker.start();
// You may use the shared ticker to render...
let renderer = new Tiny.CanvasRenderer(800, 600);
let stage = new Tiny.Container();
document.body.appendChild(renderer.view);
ticker.add(function (time) {
 renderer.render(stage);
});
// Or you can just update it manually.
ticker.autoStart = false;
ticker.stop();
function animate(time) {
 ticker.update(time);
 renderer.render(stage);
 requestAnimationFrame(animate);
}
animate(performance.now());
Documentation generated by JSDoc 3.4.3 on Mon Dec 03 2018 17:48:53 GMT+0800 (CST)