Classes
Members
(readonly) DYNAMIC :number
- Description:
- Body2D type that dictates a body can move and respond to collisions.
- Source:
Body2D type that dictates a body can move and respond to collisions.
Type:
- number
(readonly) STATIC :number
- Description:
- Body2D type that dictates a body cannot move nor respond to collisions.
- Source:
Body2D type that dictates a body cannot move nor respond to collisions.
Type:
- number
aabbDetectionOnly :boolean
- Description:
- Whether the body should detect collisions with bounds only.If true,no collision response will occur.Precollision event only will be fired.
- Source:
- Default Value:
- Settings.aabbDetectionOnly
Whether the body should detect collisions with bounds only.If true,no collision response will occur.Precollision event only will be fired.
Type:
- boolean
allowSleep :boolean
- Description:
- Whether the body should sleep when at rest or not.
- Source:
- Default Value:
- Settings.allowSleep
Whether the body should sleep when at rest or not.
Type:
- boolean
autoUpdateBound :boolean
- Description:
- Whether or not the bounds should be automatically updated.
- Source:
- Default Value:
- Settings.autoUpdateBound
Whether or not the bounds should be automatically updated.
Type:
- boolean
boundPadding :number
- Description:
- The padding of the body's bounds.
- Source:
- Default Value:
- Settings.boundPadding
The padding of the body's bounds.
Type:
- number
collisionResponse :boolean
- Description:
- Whether the body should respond to collisions.If false,no collision response will occur but collision events will still be fired.
- Source:
- Default Value:
- Settings.collisionResponse
Whether the body should respond to collisions.If false,no collision response will occur but collision events will still be fired.
Type:
- boolean
density :number
- Description:
- Density of a body.
- Source:
- Deprecated:
- Yes
Density of a body.
Type:
- number
(readonly) id :number
- Description:
- Unique identification of a body.
- Source:
Unique identification of a body.
Type:
- number
inertia :number
- Description:
- Rotational inertia of a body.
- Source:
- Deprecated:
- Yes
Rotational inertia of a body.
Type:
- number
inv_inertia :number
- Description:
- Inverse inertia of the body.
- Source:
Inverse inertia of the body.
Type:
- number
inv_mass :number
- Description:
- Inverse mass of the body.
- Source:
Inverse mass of the body.
Type:
- number
kineticFriction :number
- Description:
- The friction of the body between 0 and 1that affects it after it moves.
- Source:
- Default Value:
- Settings.kineticFriction
The friction of the body between 0 and 1that affects it after it moves.
Type:
- number
mask :Object
- Description:
- Used to describe how bodies will collide with each other. Bodies in the same layer or layer 0 will always collide with each other unless they are in different groups. Bodies in the same group will not collied with each other.
- Source:
- Default Value:
- -1
Used to describe how bodies will collide with each other.
Bodies in the same layer or layer 0 will always collide with each other unless they are in different groups.
Bodies in the same group will not collied with each other.
Type:
- Object
mass :number
- Source:
- Deprecated:
- Yes
Type:
- number
restitution :number
- Description:
- The bounciness of the body between 0 and 1.
- Source:
- Default Value:
- Settings.restitution
The bounciness of the body between 0 and 1.
Type:
- number
(readonly) shape :Shape
- Description:
- The shape of the body.
- Source:
The shape of the body.
Type:
sleeping :boolean
- Description:
- If the body is asleep or not.
- Source:
If the body is asleep or not.
Type:
- boolean
staticFriction :number
- Description:
- The friction of the body between 0 and 1 that affects it before it moves.
- Source:
- Default Value:
- Settings.staticFriction
The friction of the body between 0 and 1 that affects it before it moves.
Type:
- number
type :number
- Description:
- Type of a body.It includes the static and dynamic for now. Static bodies do not move and do not react to collisions. Dynamic bodies move and respond to collisions. Kinematic bodies move but do not respond to collisions.
- Source:
- Deprecated:
- Yes
Type of a body.It includes the static and dynamic for now.
Static bodies do not move and do not react to collisions.
Dynamic bodies move and respond to collisions.
Kinematic bodies move but do not respond to collisions.
Type:
- number
Example
Methods
getAnchor(index) → {Vector2}
- Description:
- Gets an anchor in its local space coordinate form. Treat the returned value as read-only.
- Source:
- Deprecated:
- Yes
Parameters:
Name | Type | Description |
---|---|---|
index |
number | the position of the |
Returns:
- Type
- Vector2
getLocalAnchor(index, targetopt, angle) → {Vector2}
- Description:
- Returns a rotated anchor relative to the body.
- Source:
- Deprecated:
- Yes
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
index |
number | The position of the anchor. | |
target |
Vector2 |
<optional> |
Vector2 to store results in. |
angle |
number |
Returns:
- Type
- Vector2
setAnchor(v) → {number}
- Description:
- Sets an anchor that is relative to the center of the body into it.The anchor's world coordinates will be updated when the body too is updated.
- Source:
- Deprecated:
- Yes
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 | The anchor arm |
Returns:
- Type
- number
(static) calculateBounds(bound, body, padding)
- Description:
- Calculates the bounds of the body
- Source:
Parameters:
Name | Type | Description |
---|---|---|
bound |
BoundingBox | |
body |
Body2D | Body2D to calculate max and min from |
padding |
Number | increases the size of the bounds |
(static) setDensity(body, density)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
body |
Body2D | |
density |
number |
(static) setInertia(body, inertia)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
body |
Body2D | |
inertia |
number |
(static) setMass(body, mass)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
body |
Body2D | |
mass |
number |
(static) setType(body, type)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
body |
Body2D | |
type |
number |
(static) update(body, position, orientation, scale, bounds)
- Description:
- This updates the world coordinates of shape and bounds.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
body |
Body2D | |
position |
Vector2 | |
orientation |
number | |
scale |
Vector2 | |
bounds |
BoundingBox |