Physics.P2.Body#adjustCenterOfMass()

adjustCenterOfMass() Moves the shape offsets so their center of mass becomes the body center of mass. Source code: physics/p2/Body.js (Line 490)

Physics.P2.Body#addToWorld()

addToWorld() Adds this physics body to the world. Source code: physics/p2/Body.js (Line 904)

Physics.P2.Body#addShape()

addShape(shape, offsetX, offsetY, rotation) → {p2.Shape} Add a shape to the body. You can pass a local transform when adding a shape, so that the shape gets an offset and an angle relative to the body center of mass.Will automatically update the mass properties and bounding radius.If this Body had a previously set Collision Group you will need to re-apply it to the new Shape this creates. Parameters Name Type Argument Default Description shape p2.Shape The shape to add to the body. off

Physics.P2.Body#addRectangle()

addRectangle(width, height, offsetX, offsetY, rotation) → {p2.Box} Adds a Rectangle shape to this Body. You can control the offset from the center of the body and the rotation. Parameters Name Type Argument Default Description width number The width of the rectangle in pixels. height number The height of the rectangle in pixels. offsetX number <optional> 0 Local horizontal offset of the shape relative to the body center of mass. offsetY number <optional> 0 L

Physics.P2.Body#addPolygon()

addPolygon(options, points) → {boolean} Reads a polygon shape path, and assembles convex shapes from that and puts them at proper offset points. The shape must be simple and without holes.This function expects the x.y values to be given in pixels. If you want to provide them at p2 world scales then call Body.data.fromPolygon directly. Parameters Name Type Description options object An object containing the build options: Properties Name Type Argument Default Description optimalDecomp boo

Physics.P2.Body#addPlane()

addPlane(offsetX, offsetY, rotation) → {p2.Plane} Adds a Plane shape to this Body. The plane is facing in the Y direction. You can control the offset from the center of the body and the rotation. Parameters Name Type Argument Default Description offsetX number <optional> 0 Local horizontal offset of the shape relative to the body center of mass. offsetY number <optional> 0 Local vertical offset of the shape relative to the body center of mass. rotation number <opt

Physics.P2.Body#addPhaserPolygon()

addPhaserPolygon(key, object) → {Array} Reads the shape data from a physics data file stored in the Game.Cache and adds it as a polygon to this Body.The shape data format is based on the output of thecustom phaser exporter forPhysicsEditor Parameters Name Type Description key string The key of the Physics Data file as stored in Game.Cache. object string The key of the object within the Physics data file that you wish to load the shape data from. Returns Array - A list of created fi

Physics.P2.Body#addParticle()

addParticle(offsetX, offsetY, rotation) → {p2.Particle} Adds a Particle shape to this Body. You can control the offset from the center of the body and the rotation. Parameters Name Type Argument Default Description offsetX number <optional> 0 Local horizontal offset of the shape relative to the body center of mass. offsetY number <optional> 0 Local vertical offset of the shape relative to the body center of mass. rotation number <optional> 0 Local rotation of

Physics.P2.Body#addLine()

addLine(length, offsetX, offsetY, rotation) → {p2.Line} Adds a Line shape to this Body.The line shape is along the x direction, and stretches from [-length/2, 0] to [length/2,0].You can control the offset from the center of the body and the rotation. Parameters Name Type Argument Default Description length number The length of this line (in pixels) offsetX number <optional> 0 Local horizontal offset of the shape relative to the body center of mass. offsetY number <opti

Physics.P2.Body#addFixture()

addFixture(fixtureData) → {array} Add a polygon fixture. This is used during #loadPolygon. Parameters Name Type Description fixtureData string The data for the fixture. It contains: isSensor, filter (collision) and the actual polygon shapes. Returns array - An array containing the generated shapes for the given polygon. Source code: physics/p2/Body.js (Line 1350)