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-action

v1.0.2

Published

pixi-action is a plugin for Pixi.js to create actions and animations easily.

Downloads

9

Readme

pixi-action

pixi-action is a plugin for Pixi.js to create actions and animations easily. API inspired by Cocos2d-x. Online demo here.

Build Status npm npm npm

1. Install

npm install pixi-action

require it, or import it with script tag, all is OK.

2. Usage

Code just like below.

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

var sprite1 = new Sprite(resources['res/img/animal.png'].texture);

// here is the action define.
// similar with cocos2d-x.
var action_move = new PIXI.action.MoveTo(500, 400, 2);
// run the action with actionManager.
var animation = PIXI.actionManager.runAction(cat, action_moveto);
// listen the event, include: start, end.
animation.on('end', function(elapsed) {
  console.log('action end.');
});

function animate() {
  window.requestAnimationFrame(animate);
  renderer.render(stage);
  PIXI.actionManager.update(); // update actions
}
animate();

Action defines are similar with cocos2d-x.

3. How it works

This plugin add a new namespace named action to the PIXI namespace, and the action namespace has 2 new classes, ActionManager and Action, and create an instance for ActionManager in PIXI.actionManager, but all you need is add PIXI.actionManager.update() in your requestAnimationFrame. You can pass as params for PIXI.actionManager.update(delta) your own delta time, if you don't pass anything it will be calculated internally.

For max accuracy calculating the delta time you can use the AnimationLoop plugin.

When a action is started, or ended, it will fire events named start / end.

4. Using AnimationLoop

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

var animationLoop = new PIXI.AnimationLoop(renderer);

//Add a postrender or prerender event to add the timer.update in the raf.
animationLoop.on('postrender', function() {
  PIXI.actionManager.update(this.delta); //Pass as param the delta time to PIXI.timerManager.update
});

animationLoop.start();

5. Events

TimerManager extends from PIXI.utils.EventEmitter, and emit some events: start, end, repeat, update and stop. More info: Node.js Events

  • start - callback(elapsedTime): Fired when the action starts.
  • end - callback(elapsedTime): Fired when the action is ended.

6. Actions & Animations

Now pixi-action supported actions / animations below. You can just combine them for complex actions.

  • [x] ActionMove

PIXI.action.MoveTo(x, y, time); PIXI.action.MoveBy(x, y, time);

  • [x] ActionScale

PIXI.action.ScaleTo(x, y, time); PIXI.action.ScaleBy(x, y, time);

  • [x] ActionRotate

PIXI.action.RotateTo(rotation, time); PIXI.action.RotateBy(rotation, time);

  • [x] ActionBlink

PIXI.action.Blink(count, time);

  • [x] ActionFade

PIXI.action.FadeIn(time); PIXI.action.FadeOut(time);

  • [x] ActionSkew

PIXI.action.SkewTo(x, y, time); PIXI.action.SkewBy(x, y, time);

  • [x] ActionPivot

PIXI.action.PivotTo(x, y, time); PIXI.action.PivotBy(x, y, time);

  • [x] ActionTint

PIXI.action.TintTo(tint, time); PIXI.action.TintBy(tint, time);

  • [x] ActionAlpha

PIXI.action.AlphaTo(alpha, time); PIXI.action.AlphaBy(alpha, time);

  • [x] ActionSequence

PIXI.action.Sequence(actions);

  • [x] Spawn

PIXI.action.Spawn(actions);

  • [X] ActionRepeat

PIXI.action.Repeat(action, count);

  • [x] repeatForever

PIXI.action.Repeat(action);

  • [x] ActionDelay

PIXI.action.DelayTime(time);

  • [x] ActionCallFunc

PIXI.action.CallFunc(func);

7. API

  • PIXI.actionManager.runAction(object, action): run action on an object, return an animation, can on the events.
  • PIXI.actionManager.cancelAction(AnimationObject): cancel the animation.
  • new PIXI.action.*(args): create an action.

LICENSE

MIT@hustcc. Welcome to Submit Pull Request.