Jump to content

ticker example


fire7side
 Share

Recommended Posts

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.

 

Link to comment
Share on other sites

  • 1 year later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...