Skip to content

Interface: IPhysicsWorld2D ​

Core interface types.

Methods ​

CreateBody() ​

ts
CreateBody(def): IPhysicsBody2D;

Parameters ​

ParameterType
defBody2DDef

Returns ​

IPhysicsBody2D


CreateJoint() ​

ts
CreateJoint(def): IPhysicsJoint2D | null;

Null when the definition is degenerate (same body twice, zero length, ...).

Parameters ​

ParameterType
defJoint2DDef

Returns ​

IPhysicsJoint2D | null


Destroy() ​

ts
Destroy(): void;

Returns ​

void


DestroyBody() ​

ts
DestroyBody(body): void;

Parameters ​

ParameterType
bodyIPhysicsBody2D

Returns ​

void


ForEachContact() ​

ts
ForEachContact(cb): void;

Every touching contact, with its current manifold (Stay events).

Parameters ​

ParameterType
cb(a, b, manifold) => void

Returns ​

void


GetGroundBody() ​

ts
GetGroundBody(): IPhysicsBody2D;

A static body at the origin with no fixtures — the "world" end of a joint.

Returns ​

IPhysicsBody2D


QueryPoint() ​

ts
QueryPoint(
   x, 
   y, 
   cb
): void;

Parameters ​

ParameterType
xnumber
ynumber
cb(fixture) => boolean

Returns ​

void


QueryShape() ​

ts
QueryShape(
   shape, 
   x, 
   y, 
   angle, 
   cb
): void;

Fixtures overlapping shape placed at (x, y, angle). cb returns false to stop.

Parameters ​

ParameterType
shapeShape2D
xnumber
ynumber
anglenumber
cb(fixture) => boolean

Returns ​

void


RayCast() ​

ts
RayCast(
   x1, 
   y1, 
   x2, 
   y2, 
   cb
): void;

Closest-first is the caller's job: cb returns the new max fraction (Box2D convention: 0 stops, fraction clips, 1 continues unclipped, -1 skips the fixture).

Parameters ​

ParameterType
x1number
y1number
x2number
y2number
cb(fixture, px, py, nx, ny, fraction) => number

Returns ​

void


SetAllowSleep() ​

ts
SetAllowSleep(allow): void;

Parameters ​

ParameterType
allowboolean

Returns ​

void


SetContactListener() ​

ts
SetContactListener(listener): void;

Parameters ​

ParameterType
listenerIContactListener2D | null

Returns ​

void


SetGravity() ​

ts
SetGravity(x, y): void;

Parameters ​

ParameterType
xnumber
ynumber

Returns ​

void


Step() ​

ts
Step(
   dt, 
   velocityIterations, 
   positionIterations
): void;

Parameters ​

ParameterType
dtnumber
velocityIterationsnumber
positionIterationsnumber

Returns ​

void

© 2026 PlayAdGentic