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 🙏

© 2025 – Pkg Stats / Ryan Hefner

p2Pixi

v1.0.6

Published

A simple 2D vector game model framework using p2.js for physics and Pixi.js for rendering.

Downloads

7

Readme

#p2Pixi

A simple 2D vector game model framework using p2.js for physics and Pixi.js for rendering.

Live demos:

Buggy Spinners

Games using p2Pixi:

Descensus

Below is a brief overview of the 3 classes and their key methods. Refer to the TypeScript definitions for further details.

##Game Serves as an abstract base class for your own game. Refer to the demo Game classes for example usage.

###addGameObject Adds the supplied GameObject to the Game.

###removeGameObject Defers to the remove function of the supplied GameObject

###loadAssets Loads the supplied assets asyncronously with a Pixi AssetLoader.

###runIfReady Runs the Game if the isReadyToRun function returns true. Override isReadyToRun to perform custom loading checks, for example if you are also loading sounds.

###beforeRun Called before the game loop is started.

###run Begins the world step / render loop.

###beforeRender Called before the render method. The base implementation of this method focuses the Pixi stage upon the Game's tracked p2 body, if one is set. Extend or override this method to customize scrolling behaviour.

###render Updates the Pixi representation of the world by transforming each body's Pixi representation according to its p2 properties.

###afterRender Called after the render method. Override this method to perform extra custom rendering.

##GameObject Serves as an abstract base class for your own game's game objects such as a car or a portion of terrain. Each GameObject can comprise multiple p2 bodies.

###addBody Adds the supplied p2 body to the GameObject and to the game's world, and creates a corresponding Pixi DisplayObjectContainer object for rendering.

###addShape Adds the supplied p2 shape to the supplied p2 body.

When specifying styles via options.styleOptions, lineWidth can either be specified as a Pixi line width, for example:

{ 
    lineWidth: 1
}

Or in p2 units, which take precedence, like so:

{ 
    lineWidthUnits: 0.0078125
}

Using Pixi's lineWidth means that regardless of your pixelsPerLengthUnit value, any shape outlines (if defined) will have a fixed pixel width. Using p2 units means that if you decide to change your pixelsPerLengthUnit value then all line thicknesses will scale accordingly.

###addConstraint Adds the supplied p2 constraint to the GameObject and to the game's world.

###addChild Adds the supplied GameObject as a child of this GameObject. A child is simply a logically linked GameObject.

###updateTransforms Updates the PIXI position and rotation transforms for each of this GameObject's p2 bodies. Recursively calls updateTransforms on child GameObjects.

###remove Removes the GameObject from the Game, which results in the removal of its bodies and constraints from the p2 physics world and the bodies' shapes from the Pixi rendering stage. Also removes all child GameObjects.

##PixiAdapter Handles rendering of p2 shapes into Pixi objects such as Graphics (for vector rendering) and / or Sprite / TilingSprite (for bitmap rendering).

###addShape Called by the GameObject.addShape method. Adds the supplied p2 shape to the supplied Pixi DisplayObjectContainer, using vectors and / or a texture.