npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pixi-animationloop

v1.0.9

Published

AnimationLoop is a plugin for Pixi.js v3.0.8 or higher to manage the animation frame, doing the basic time operations, like calculate delta, total time, start/stop loop, and more.

Downloads

381

Readme

pixi-animationloop

AnimationLoop is a plugin for Pixi.js v3.0.8 or higher to manage the animation frame, doing the basic time operations, like calculate delta, total time, start/stop loop, and more.

Installation

npm install pixi-animationloop

Usage

Browserify - Webpack

If you use Browserify or Webpack you can use pixi-animationloop like this:

var PIXI = require('pixi.js');
var AnimationLoop = require('pixi-animationloop'); //AnimationLoop is added automatically to the PIXI namespace

//create PIXI renderer
var renderer = new PIXI.autoDetectRenderer(800,600);
document.body.appendChild(renderer.view);

var animationLoop = new PIXI.AnimationLoop(renderer);
animationLoop.start();

Prebuilt files

var renderer = new PIXI.autoDetectRenderer(800,600);
document.body.appendChild(renderer.view);

var animationLoop = new PIXI.AnimationLoop(renderer);
animationLoop.start();

Events

AnimationLoop extends from PIXI.utils.EventEmitter, and emit four events: start, stop, prerender, postrender and visibilitychange. More info: Node.js Events

animationLoop.on('start', function(){
  console.log('onStart');
});

animationLoop.on('stop', function(){
  console.log('onStop');
});

//Before the renderer.render(stage) function
animationLoop.on('prerender', function(){
  console.log('preRender', this.delta);
});

//After the renderer.render(stage) function
animationLoop.on('postrender', function(){
  console.log('postRender', this.delta);
});

//when the visibility change, for example, when the user move on to other browser tab.
animationLoop.on('visibilitychange', function(isHide){
  //the param isHide is the state of the tab
  console.log('visibilityChange', isHide);
});

API

constructor( renderer [, stage])

The constructor

.renderer

Pixi.js renderer

.stage

Pixi.js container used as stage

.time

Total game time in seconds (stop the animation loop stops the time)

.realTime

Real time in seconds, since the first start

.delta

Delta time in seconds

.deltaMS

Delta time in milliseconds

.speed

Set the time speed (like 0.5, 1.5, 2, ...)

.maxFrame

Delta time can't be higher than maxFrame (in seconds)

.raf

Request animation frame ID

.isRunning

Used internally to know the state of the loop

.stopOnVisibilityChange

Stop the animation loop when the user move on to the other tab, when the user comes back the game will be resumed. (false by defult)

.start()

Start or resume the animation loop, emit the 'start' event

.stop()

Stops the animation loop, emit the 'stop' event