Construct a PolygonBody
The basic shape configuration for the polygon
X coordinate of the center of the polygon
Y coordinate of the center of the polygon
Vertices of the polygon, as points that are offsets relative to (cx, cy)
Optional physics configuration; see PhysicsCfg for the full set of options
A rigid body with a Polygon shape
The physics body
Height of the body
ProtectedmainThe entity's primary fixture
OptionalpassEntities with a matching Id don't collide with each other
Radius of a circumscribed circle, for culling
ReadonlysceneThe physics world where this body exists
OptionalsingleAre collisions only valid from one direction? Expressed as a zone (see
relativeZone in Behavior.ts): DIRECTION.N means "solid only when
approached from above."
Which sides of the body are sticky, if any? DIRECTION.N means "stuff
touching my top sticks."
The fastest speed, relative to this body, at which something can stick to
it. Configured via PhysicsCfg.stickySpeedLimit.
Width of the body
The type of this body: "static" (never moves), "kinematic" (moves only as it is told to), or "dynamic" (moves and responds to forces and collisions). Assign to it to change the type while the game is running.
Change the type of this body
Report if this entity's main shape causes transfer of momentum when it
collides with other entities (true) or not (false). This only
concerns the main fixture -- the proximity fixture (see
proximityRadius), if any, is always a sensor, regardless of this
setting.
Indicate whether this entity engages in physics collisions or not
True or false, depending on whether the entity will participate in physics collisions or not
The radius (in meters) of this entity's proximity-sensor zone, or
undefined if it has none.
Give this entity a proximity-sensor zone: a second, sensor-only
fixture on the same body, separate from its normal solid fixture, so
it can have both real physical collisions (or none, if
collisionsEnabled is false) and a much larger "something is nearby"
detection radius at the same time. Box2D fires contact events for
this fixture exactly like any other, but Services/Collisions.ts
routes them to ProximityBehavior instead of the normal collision
dispatch. Pass undefined to remove an existing proximity zone.
NB: Unlike the entity's main shape, the proximity radius does not
automatically rescale when resize() is called.
The radius of the proximity zone, in meters, or
undefined to remove it
The current rotation of the entity, in radians
The current rotation of the entity, in radians
A joint for fusing entities together when one is "sticky"
The X velocity of this actor
Update the X velocity, without affecting the Y velocity
The Y velocity of this actor
Update the Y velocity, without affecting the X velocity
Add a revolute joint between this entity and some other entity, so that this entity can turn around a point on the other one. An entity can have as many joints as you like. Note that both entities need to have some mass (density can't be 0) or else this won't work.
The joint that comes back can be changed later, such as with
joint.SetMotorSpeed(speed), joint.SetMaxMotorTorque(torque), and
joint.EnableMotor(true).
The entity around which this entity will rotate
The point (relative to center) where the joint fuses to the anchor
Optionallimits?: { lower: number; upper: number }Optional bounds on the rotation, in radians
The point (relative to center) where the joint fuses to this entity
Optionalmotor?: { speed: number; torque: number }Optional motor to make the joint turn: speed is
in radians per second, and when in doubt, give a
torque that is huge, like positive infinity
The joint that was created
Add velocity to this actor
Velocity in X dimension
Velocity in Y dimension
Create a weld joint between this entity and some other entity, to force the entities to stick together.
The angle between the entities
The point (relative to center) where the joint fuses to this entity
The entity that will be fused to this entity
The point (relative to center) where the joint fuses to the other entity
The joint that was created
Apply a force to the actor
The force to apply in the x dimension
The force to apply in the y dimension
Make the entity stop rotating
Remove this entity's punch hitbox if it has one
Give this entity a punch hitbox: a third, sensor-only fixture on the
same body, offset from its center, so a melee attack can be modeled as
a circle that moves rigidly with this entity -- no separate actor, no
joint. Box2D fires contact events for this fixture exactly like any
other; Services/Collisions.ts routes them to PunchBehavior instead
of the normal collision dispatch. Replaces any punch hitbox already in
progress; see disablePunch to remove it without replacing it.
The x distance from this entity's center to the hitbox's center
The y distance from this entity's center to the hitbox's center
The radius of the hitbox
ProtectedfinishCopy an old fixture's density/elasticity/friction/sensor state onto
mainFixture (the fixture that just replaced it), then destroy the old
one. Shared by every subclass's resize(), since this tail is
identical regardless of shape.
The fixture that mainFixture is replacing
Return the center of the entity
Report the current velocity of this body
Change the rotation of the body
How much to add to the current rotation
Resize a PolygonBody
The amount to scale the size by. 1 means "no change", >1 means "grow", fraction means "shrink".
Set a dampening factor to cause a spinning body to decrease its rate of spin
The amount of damping to apply
Change the position of an entity
The new X position, in meters
The new Y position, in meters
Set a dampening factor to cause a moving body to slow down without colliding with anything
The amount of damping to apply
Indicate that this actor should be immune to the force of gravity
Adjust the default physics settings (density, elasticity, friction) for this entity
Optionaldensity?: numberNew density of the entity
Optionalelasticity?: numberNew elasticity of the entity
Optionalfriction?: numberNew friction of the entity
Indicate whether this body is allowed to rotate or not
Update the velocity
The new x velocity
The new y velocity
ProtectedupdateUpdate physics properties
A description of which properties to change
A rigid body whose underlying shape is a convex polygon