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

k8w-pixi-tween

v0.7.6

Published

pixi-tween is a tween plugin for Pixi.js v4.1.0 or higher

Downloads

42

Readme

pixi-tween

pixi-tween is a plugin for Pixi.js v4.1.0 or higher to create tween animations.

API documentation

JSDocs

Usage

Rollup / Browserify / Webpack

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

import * as PIXI from ('pixi.js');
import tweenManager from ('pixi-tween');

const app = new PIXI.Application(800, 600);
document.body.appendChild(app.view);

// Listen for animate update and update the tween manager
app.ticker.add(function(delta) {
    PIXI.tweenManager.update();
});

Prebuilt files

If not, the namespaces are automatically added to global anyway

const app = new PIXI.Application(800, 600);
document.body.appendChild(app.view);

// Listen for animate update and update the tween manager
app.ticker.add(function(delta) {
    PIXI.tweenManager.update();
});

How it works

This plugin add a new namespace names tween to the PIXI namespace, and this new namespace has 3 new classes Tween, TweenPath and TweenManager, also add an Easing object.

A tweenManager is automatically created for you in PIXI.tweenManager, which you need to update on ticks via PIXI.tweenManager.update(). You can create your own tweenManagers via new PIXI.tween.TweenManager, and you can also manually update the timings of a manager via PIXI.tweenManager.update(deltaMS)

When a tween is ended, the instance will kept in the memory and in the tweenManager, but you can prevent this if you set .expire = true in the tween.

Events

Tween extends from PIXI.utils.EventEmitter, and emit some events: start, end, repeat, update, stop and pingpong. You can read about these in the api documentation under PIXI.tween.Tween.

Paths

Move an object along a path it's easy with TweenPath. TweenPath use a similar PIXI.Graphics API to create paths, and once it's created our path we just need to add it to a tween with .path = ourPathCreated.

If you need draw your path (useful to debug), PIXI.Graphics has been enhanced with a new method named .drawPath(path). Use it the same way like .drawRectanle, .drawShape, etc...

Basic example

const app = new PIXI.Application(800, 600);
document.body.appendChild(app.view);

const sprite = new PIXI.Sprite(PIXI.Texture.WHITE);
const tween = PIXI.tweenManager.createTween(sprite);
tween.from({ x: 0 }).to({ x: 250 })
tween.time = 1000;
tween.repeat = 10;
tween.on('start', () => { console.log('tween started') });
tween.on('repeat', ( loopCount ) => { console.log('loopCount: ' + loopCount) });
tween.start();

// Listen for animate update and update the tween manager
app.ticker.add(function(delta) {
    PIXI.tweenManager.update();
});

Other examples

Easing TweenPath