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. | ||
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 the shape relative to the body center of mass, specified in radians. |
Returns
p2.Shape -
The shape that was added to the body.
- Source code: physics/p2/Body.js (Line 992)
Please login to continue.