Ball

Ball

A body with a circle shape on it.

Constructor

new Ball(radius)

Source:
Parameters:
Name Type Description
radius number

Extends

Classes

Ball

Members

(readonly) DYNAMIC :number

Description:
  • Body2D type that dictates a body can move and respond to collisions.
Source:
Overrides:
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:
Overrides:
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:
Overrides:
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:
Overrides:
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:
Overrides:
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:
Overrides:
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:
Overrides:
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:
Overrides:
Deprecated:
  • Yes
Density of a body.
Type:
  • number

(readonly) id :number

Description:
  • Unique identification of a body.
Source:
Overrides:
Unique identification of a body.
Type:
  • number

inertia :number

Description:
  • Rotational inertia of a body.
Source:
Overrides:
Deprecated:
  • Yes
Rotational inertia of a body.
Type:
  • number

inv_inertia :number

Description:
  • Inverse inertia of the body.
Source:
Overrides:
Inverse inertia of the body.
Type:
  • number

inv_mass :number

Description:
  • Inverse mass of the body.
Source:
Overrides:
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:
Overrides:
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:
Overrides:
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:
Overrides:
Deprecated:
  • Yes
Type:
  • number

restitution :number

Description:
  • The bounciness of the body between 0 and 1.
Source:
Overrides:
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:
Overrides:
The shape of the body.
Type:

sleeping :boolean

Description:
  • If the body is asleep or not.
Source:
Overrides:
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:
Overrides:
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:
Overrides:
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:
Overrides:
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:
Overrides:
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:
Overrides:
Deprecated:
  • Yes
Parameters:
Name Type Description
v Vector2 The anchor arm
Returns:
Type
number