Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • Body

Implements

Index

Constructors

constructor

  • new Body(__namedParameters: object): Body

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: 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

center

collider

id

  • get id(): number

isColliderShapeDirty

  • get isColliderShapeDirty(): boolean

Methods

addMtv

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

    Parameters

    Returns void

applyMtv

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

    Returns void

captureOldTransform

  • captureOldTransform(): void

clone

integrate

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

    Parameters

    • delta: number

    Returns void

markCollisionShapeDirty

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

    Returns void

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.

    Parameters

    • width: number
    • height: number
    • Default value anchor: Vector = Vector.Half
    • Default value center: Vector = Vector.Zero

    Returns Collider

Obsolete useBoxCollision

  • useBoxCollision(center?: Vector): void

useCircleCollider

Obsolete useCircleCollision

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

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.

    Parameters

    Returns Collider

Obsolete useEdgeCollision

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.

    Parameters

    • points: Vector[]
    • Default value center: Vector = Vector.Zero

    Returns Collider

Obsolete usePolygonCollision

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