Represents the size of a meter in pixels.
Adjusting this property changes the simulated scale of the physics world. For optimal results, it should be set such that sprites are between 0.1 and 10 meters in size in the physics simulation.
The default value is 60, which means that your sprites should optimally be between 6 and 600 pixels in size.
The time elapsed in the physics simulation in seconds.
The number of sub-steps per physics update. More sub-steps increases accuracy at the cost of performance.
The Box2D world ID. Don't change it!
"Sleeping" sprites get temporarily ignored during physics simulation. A sprite starts "sleeping" when it stops moving and doesn't collide with anything that it wasn't already touching.
This is an important performance optimization that you probably shouldn't disable for every sprite in the world.
The number of physics bodies currently awake in the world.
Box2D world counter/statistics data.
The minimum impact velocity needed for a hit event to be fired.
Box2D world performance profile data.
The real time in seconds since the world was created, including time spent paused.
The fixed update rate of the physics simulation in hertz.
The time step, the amount of time that passes during a physics update, is calculated to be: 1 / updateRate * timeScale
Setting the update rate to a value lower than 50hz is not recommended, as simulation quality will degrade.
Finds the first sprite (with a physics body) that intersects a swept circle (capsule cast) from startPos to endPos.
starting position of the cast, object with x and y properties or array [x, y]
end position of the cast
radius of the circle
The first sprite hit or undefined
Finds all sprites (with physics bodies) that intersect a swept circle (capsule cast) from startPos to endPos, sorted by distance.
starting position of the cast
end position of the cast
radius of the circle
Optionallimiter: Functioncallback run each time the cast hits a sprite; return true to stop the cast
An array of sprites hit, sorted by distance.
Applies an explosive force to sprites within the radius of the explosion.
x coordinate or object with x and y properties of the center of the explosion
Optionalradius: numberthe distance from the center of the explosion that sprites can be affected by the explosion
Optionalmagnitude: numberthe strength of the explosion force, default is 1
Optionalfalloff: numberhow much the explosion force decreases as sprites are farther from the center of the explosion, default is 0.1 (10% decrease per pixel)
Applies an explosive force to sprites within the radius of the explosion.
Optionalradius: numberthe distance from the center of the explosion that sprites can be affected by the explosion
Optionalmagnitude: numberthe strength of the explosion force, default is 1
Optionalfalloff: numberhow much the explosion force decreases as sprites are farther from the center of the explosion, default is 0.1 (10% decrease per pixel)
Returns the sprite at the specified position on the top most layer, drawn when the camera was on.
The sprite must have a physics body to be detected.
x coordinate or object with x and y properties
Optionalradius: numberthe distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
Optionalgroup: Groupthe group to search
a sprite
Returns the sprite at the specified position on the top most layer, drawn when the camera was on.
The sprite must have a physics body to be detected.
object with x and y properties
Optionalradius: numberthe distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
Optionalgroup: Groupthe group to search
a sprite
Returns the sprites at a position, ordered by layer.
Sprites must have a physics body to be detected.
x coordinate or object with x and y properties
Optionalradius: numberthe distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
Optionalgroup: Grouplimit results to a specific group, allSprites by default
OptionalcameraActiveWhenDrawn: booleanlimit results to sprites drawn when the camera was active, true by default
an array of sprites
Returns the sprites at a position, ordered by layer.
Sprites must have a physics body to be detected.
object with x and y properties
Optionalradius: numberthe distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
Optionalgroup: Grouplimit results to a specific group, allSprites by default
OptionalcameraActiveWhenDrawn: booleanlimit results to sprites drawn when the camera was active, true by default
an array of sprites
Performs a physics simulation step that advances all sprites forward in time by 1 / updateRate * timeScale if no timeStep is given.
OptionaltimeStep: numberFinds the first sprite (with a physics body) that intersects a ray (line).
starting position of the ray cast, object with x and y properties or array [x, y]
direction angle of the ray
OptionalmaxDistance: numbermax distance the ray should check, default 10000
The first sprite the ray hits or undefined
Finds the first sprite (with a physics body) that intersects a ray from startPos to endPos.
starting position of the ray cast
end position of the ray cast
The first sprite the ray hits or undefined
Finds all sprites (with physics bodies) that intersect a ray (line), sorted by distance.
starting position of the ray cast, object with x and y properties or array [x, y]
direction angle of the ray
OptionalmaxDistance: numbermax distance the ray should check, default 10000
Optionallimiter: Functioncallback run each time the ray hits a sprite; return true to stop the ray
An array of sprites that the ray cast hit, sorted by distance. The sprite closest to the starting point will be at index 0. If a limiter is provided, this array includes the sprite that caused the ray to stop.
Finds all sprites (with physics bodies) that intersect a ray from startPos to endPos, sorted by distance.
starting position of the ray cast
end position of the ray cast
Optionallimiter: Functioncallback run each time the ray hits a sprite; return true to stop the ray
An array of sprites that the ray cast hit, sorted by distance.
Alias for physicsUpdate.
OptionaltimeStep: number
The World is the Box2D physics simulation.