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 current 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.25.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.25.0

sx

sx: number = 0

The x scalar velocity of the actor in scale/second

obsolete

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

sy

sy: number = 0

The y scalar velocity of the actor in scale/second

obsolete

ex.Body.scale will be removed in v0.25.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

applyMtv

  • applyMtv(): void

captureOldTransform

  • captureOldTransform(): void

clone

integrate

  • integrate(delta: number): void

markCollisionShapeDirty

  • markCollisionShapeDirty(): void

useBoxCollider

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

    If no width/height are specified the body will attempt to use the associated actor's width/height.

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

    Parameters

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

    Returns Collider

useCircleCollider

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.

    Parameters

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

    Returns Collider