fire7side Posted February 18, 2016 Share Posted February 18, 2016 I've been reading the docs about the ticker class but I can't get my head around it. I was wondering if someone could give a short example of a function being added to it. Quote Link to comment Share on other sites More sharing options...
fire7side Posted February 18, 2016 Author Share Posted February 18, 2016 So, it looks like this doesn't get used much right? I saw a program which used the javascript Date class, which might be better. Quote Link to comment Share on other sites More sharing options...
themoonrat Posted February 18, 2016 Share Posted February 18, 2016 Here's an super basic example of using the shared one wrapped up using an ES6 style class. class TickManager { constructor( settings ) { PIXI.ticker.shared.add( this._onTickEvent, this ); } destroy() { PIXI.ticker.shared.remove( this._onTickEvent, this ); } _onTickEvent( deltaTime ) { console.log( deltaTime ); } } It's a replacement for requestAnimationFrame for my usage. That way if I want to pause the game, I can just stop the timer. If for debug reasons I want to speed up / slow down the game, I can do it on the timer, instead of manipulating a rAF calls. And the positives of it being based on rAF is that if you minimise the browser, the timer is essentially paused until you maximise it again. Quote Link to comment Share on other sites More sharing options...
fire7side Posted February 19, 2016 Author Share Posted February 19, 2016 OK, that helped, thanks. I'm not doing Es6 yet, but I can see how it works now. Quote Link to comment Share on other sites More sharing options...
chatrano Posted March 4, 2017 Share Posted March 4, 2017 I built a lib to handle the ticker when the browser struggle the RAF calls: https://github.com/francoagusto/ticker/ ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.