Pixi.js: How ticker.speed works

Created on 9 Dec 2016  ·  3Comments  ·  Source: pixijs/pixi.js

As document says
// Scales ticker.deltaTime to what would be
// the equivalent of approximately 120 FPS
ticker.speed = 2;

if i set ticker.speed = .5 the whole render should play at 30fps?right?
but it does not work.

🤔 Question

Most helpful comment

PIXI only renders when you tell it to render. If you hook it up to requestAnimationFrame, then that gets called whenever the browser can draw again; changing the shared ticker does not effect this at all.

Even if you did hook up renderer.render to a PIXI ticker, it would still call back 60 times a second. You see, the speed factor effects the deltaTime value that is passed in when a ticker updates, not how often it is called.

So, if the game was running at 60fps, then at a scale of 1, then the tick update would be called 60 times a second, each time with a deltaTime of 1. But if you set the scale to 0.5, then the tick update would be called 60 times a second, but with the deltaTime of 0.5.

@readygosports Could you provide a jsfiddle of what you mean please if the above doesn't cover your question :)

All 3 comments

PIXI only renders when you tell it to render. If you hook it up to requestAnimationFrame, then that gets called whenever the browser can draw again; changing the shared ticker does not effect this at all.

Even if you did hook up renderer.render to a PIXI ticker, it would still call back 60 times a second. You see, the speed factor effects the deltaTime value that is passed in when a ticker updates, not how often it is called.

So, if the game was running at 60fps, then at a scale of 1, then the tick update would be called 60 times a second, each time with a deltaTime of 1. But if you set the scale to 0.5, then the tick update would be called 60 times a second, but with the deltaTime of 0.5.

@readygosports Could you provide a jsfiddle of what you mean please if the above doesn't cover your question :)

Closing as this seems answered! Cheers!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lucap86 picture lucap86  ·  3Comments

Vardner picture Vardner  ·  3Comments

Makio64 picture Makio64  ·  3Comments

zcr1 picture zcr1  ·  3Comments

gaccob picture gaccob  ·  3Comments