Options
All
• Public
• Public/Protected
• All

# Class Body

Body describes all the physical properties pos, vel, acc, rotation, angular velocity

• Body

## Constructors

### constructor

• new Body(__namedParameters: object): Body
• Constructs a new physics body associated with an actor

## Properties

### acc

acc: Vector = new Vector(0, 0)

The curret acceleration vector (ax, ay) of the actor in pixels/second/second. An acceleration pointing down such as (0, 100) may be useful to simulate a gravitational effect.

actor: Actor

### motion

motion: number = 10

The current "motion" of the actor, used to calculated sleep in the physics simulation

### oldAcc

oldAcc: Vector = Vector.Zero

Gets/sets the acceleration of the actor from the last frame. This does not include the global acc Physics.acc.

### oldPos

oldPos: Vector = new Vector(0, 0)

The position of the actor last frame (x, y) in pixels

### oldRotation

oldRotation: number = 0

Gets/sets the rotation of the body from the last frame.

### oldScale

oldScale: Vector = Vector.One

The scale of the actor last frame

obsolete

ex.Body.scale will be removed in v0.24.0

### oldVel

oldVel: Vector = new Vector(0, 0)

The velocity of the actor last frame (vx, vy) in pixels/second

### pos

pos: Vector = new Vector(0, 0)

The (x, y) position of the actor this will be in the middle of the actor if the Actor.anchor is set to (0.5, 0.5) which is default. If you want the (x, y) position to be the top left of the actor specify an anchor of (0, 0).

### rotation

rotation: number = 0

The rotation of the actor in radians

### rx

rx: number = 0

The rotational velocity of the actor in radians/second

### scale

scale: Vector = Vector.One

The scale vector of the actor

obsolete

ex.Body.scale will be removed in v0.24.0

### sx

sx: number = 0

The x scalar velocity of the actor in scale/second

obsolete

ex.Body.scale will be removed in v0.24.0

### sy

sy: number = 0

The y scalar velocity of the actor in scale/second

obsolete

ex.Body.scale will be removed in v0.24.0

### torque

torque: number = 0

The current torque applied to the actor

### vel

vel: Vector = new Vector(0, 0)

The current velocity vector (vx, vy) of the actor in pixels/second

## Accessors

### active

• get active(): boolean

### id

• get id(): number

### isColliderShapeDirty

• get isColliderShapeDirty(): boolean

## Methods

• Add minimum translation vectors accumulated during the current frame to resolve collisions.

### applyMtv

• applyMtv(): void
• Applies the accumulated translation vectors to the actors position

### captureOldTransform

• captureOldTransform(): void
• Sets the old versions of pos, vel, acc, and scale.

### integrate

• integrate(delta: number): void
• Perform euler integration at the specified time step

### markCollisionShapeDirty

• markCollisionShapeDirty(): void
• Flags the shape dirty and must be recalculated in world space

### useBoxCollider

• Sets up a box geometry based on the current bounds of the associated actor of this physics body.

By default, the box is center is at (0, 0) which means it is centered around the actors anchor.

### Obsolete useBoxCollision

• useBoxCollision(center?: Vector): void
• obsolete

Body.useBoxCollision will be removed in v0.24.0 use Body.useBoxCollider

### useCircleCollider

• Sets up a circle collision geometry with a specified radius in pixels.

By default, the box is center is at (0, 0) which means it is centered around the actors anchor.

### Obsolete useCircleCollision

• useCircleCollision(radius?: number, center?: Vector): void
• obsolete

Body.useCircleCollision will be removed in v0.24.0, use Body.useCircleCollider

### useEdgeCollider

• Sets up an edge collision geometry with a start point and an end point relative to the anchor of the associated actor of this physics body.

By default, the box is center is at (0, 0) which means it is centered around the actors anchor.

### Obsolete useEdgeCollision

• obsolete

Body.useEdgeCollision will be removed in v0.24.0, use Body.useEdgeCollider

### usePolygonCollider

• Sets up a convex polygon collision geometry based on a list of of points relative to the anchor of the associated actor of this physics body.

Only convex polygon definitions are supported.

By default, the box is center is at (0, 0) which means it is centered around the actors anchor.

### Obsolete usePolygonCollision

• usePolygonCollision(points: Vector[], center?: Vector): void
• obsolete

Body.usePolygonCollision will be removed in v0.24.0 use Body.usePolygonCollider