⭐ Click here for special offer ⭐

Plugin Documentation

p2.js plugin replaces these Panda classes with p2.js versions:

  • Physics
  • Body

Body class also includes additional addTo and remove functions.

For shapes use p2.js classes (p2.Box, p2.Circle, p2.Convex etc).

p2.js API Documentation


p2.js uses meters instead of pixels. To convert pixels to meters, divide pixels with world.ratio. To convert meters to pixels, multiply values with world.ratio.

// Pixels to meters
body.position[0] = sprite.position.x / body.world.ratio;
body.position[1] = sprite.position.y / body.world.ratio;


You can define debug color for sensor shapes with sensorColor in game.config:

debug: {
    sensorColor: '#00ff00'


You can use physics data created with PhysicsEditor. Export JSON file from PhysicsEditor using Panda 2 exporter.

Load JSON file exported from PhysicsEditor:


Create body from JSON file with game.Body.fromData function:

var body = game.Body.fromData('banana.json', 'banana');

First parameter is the name of the JSON file and second is name of the sprite defined in PhysicsEditor. If the name is same as the JSON file (without .json extension), you can skip that parameter.

PhysicsEditor JSON can be also used with PhysicsSprite:

var banana = new game.PhysicsSprite('banana.png', game.width / 2, game.height / 2, {
    data: 'banana.json',
    name: 'banana'

See PhysicsEditor scene in example project for example usage.



  • Added more example scenes


  • Fixed issue with engine 2.8.1


  • Added support for PhysicsEditor