After evaluating a few other physics libraries, I am now in favour of Nape and it works well with pixi.js. Click here for a quick demo and source code.
I will not be actively maintaining these externs anymore, so if anyone is interested please let me know and I will add them as collaborators.
haxe-p2
Externs of p2.js for Haxe - A Javascript 2D physics library.
Installation
haxelib install p2js
Please note that this is an alpha release and the development/testing is still in progress.
Usage
import pixiimport pixiimport pixi import p2import p2import p2import p2import p2 class Main { var _renderer:Dynamic; var _stage:Stage; var _p2World:World; var _p2container:DisplayObjectContainer; var _p2graphics:Graphics; var _boxBody:Body; var _p2Circle:Graphics; var _circleShape:Circle; var _p2Sensor:Graphics; var _sensorShape:Circle; var _circleBody:Body; var _sensorBody:Body; public function new() { _stage = new Stage _renderer = Detector600); Browser _p2World = new World({ gravity:[0, 0] }); var boxShape:Rectangle = new Rectangle1); _boxBody = new Body({ mass: 1, position:[0, 2], angularVelocity: 1 }); _boxBody _p2World var planeShape:Plane = new Plane(); var planeBody:Body = new Body({ position:[0, -1] }); planeBody _p2World var zoom:Int = 100; _p2container = new DisplayObjectContainer(); gameStage _p2container= StageProperties/ 2; _p2container= StageProperties/ 2; _p2container= zoom; _p2container= -zoom; _p2graphics = new Graphics(); _p2graphics _p2graphics/ 2, -boxShape/ 2, boxShapeboxShape _p2container _circleShape = new Circle _circleBody = new Body({ mass: 1 }); _circleBody= 0; _circleBody _p2World _p2Circle = new Graphics(); _p2Circle _p2Circle0, _circleShape _p2container Browseranimate); } function animate() { Browseranimate); _p2World _p2graphics= _boxBody _p2graphics= _boxBody _p2graphics= _boxBody _renderer }}
This content is released under the MIT License.
p2.js is maintained by schteppe.