Class: World

Phaser.Physics.Arcade. World

The Arcade Physics World.

The World is responsible for creating, managing, colliding and updating all of the bodies within it.

An instance of the World belongs to a Phaser.Scene and is accessed via the property physics.world.


new World(scene, config)

Parameters:
Name Type Description
scene Phaser.Scene

The Scene to which this World instance belongs.

config ArcadeWorldConfig

An Arcade Physics Configuration object.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 150)

Extends

Members


bodies :Phaser.Structs.Set.<Phaser.Physics.Arcade.Body>

Dynamic Bodies in this simulation.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 186)

bounds :Phaser.Geom.Rectangle

A boundary constraining Bodies.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 231)

checkCollision :CheckCollisionObject

The boundary edges that Bodies can collide with.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 245)

colliders :Phaser.Structs.ProcessQueue.<Phaser.Physics.Arcade.Collider>

This simulation's collision processors.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 213)

debugGraphic :Phaser.GameObjects.Graphics

The graphics object drawing the debug display.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 393)

defaults :ArcadeWorldDefaults

Default debug display settings for new Bodies.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 402)

drawDebug :boolean

Enables the debug display.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/World.js (Line 383)

forceX :boolean

Always separate overlapping Bodies horizontally before vertically.
False (the default) means Bodies are first separated on the axis of greater gravity, or the vertical axis if neither is greater.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/World.js (Line 351)

<readonly> fps :number

The number of physics steps to be taken per second.

This property is read-only. Use the setFPS method to modify it at run-time.

Type:
  • number
Since: 3.10.0
Default Value:
  • 60
Source: src/physics/arcade/World.js (Line 259)

gravity :Phaser.Math.Vector2

Acceleration of Bodies due to gravity, in pixels per second.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 222)

isPaused :boolean

Whether the simulation advances with the game loop.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/physics/arcade/World.js (Line 362)

maxEntries :integer

The maximum number of items per node on the RTree.

This is ignored if useTree is false. If you have a large number of bodies in
your world then you may find search performance improves by increasing this value,
to allow more items per node and less node division.

Type:
  • integer
Since: 3.0.0
Default Value:
  • 16
Source: src/physics/arcade/World.js (Line 418)

OVERLAP_BIAS :number

The maximum absolute difference of a Body's per-step velocity and its overlap with another Body that will result in separation on each axis.
Larger values favor separation.
Smaller values favor no separation.

Type:
  • number
Since: 3.0.0
Default Value:
  • 4
Source: src/physics/arcade/World.js (Line 326)

pendingDestroy :Phaser.Structs.Set.<(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)>

Static Bodies marked for deletion.

Type:
Since: 3.1.0
Source: src/physics/arcade/World.js (Line 204)

scene :Phaser.Scene

The Scene this simulation belongs to.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 177)

staticBodies :Phaser.Structs.Set.<Phaser.Physics.Arcade.StaticBody>

Static Bodies in this simulation.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 195)

staticTree :Phaser.Structs.RTree

The spatial index of Static Bodies.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 464)

<readonly> stepsLastFrame :number

The number of steps that took place in the last frame.

Type:
  • number
Since: 3.10.0
Source: src/physics/arcade/World.js (Line 302)

TILE_BIAS :number

The maximum absolute value of a Body's overlap with a tile that will result in separation on each axis.
Larger values favor separation.
Smaller values favor no separation.
The optimum value may be similar to the tile size.

Type:
  • number
Since: 3.0.0
Default Value:
  • 16
Source: src/physics/arcade/World.js (Line 338)

timeScale

Scaling factor applied to the frame rate.

  • 1.0 = normal speed
  • 2.0 = half speed
  • 0.5 = double speed
Properties:
Type Description
number
Since: 3.10.0
Default Value:
  • 1
Source: src/physics/arcade/World.js (Line 312)

tree :Phaser.Structs.RTree

The spatial index of Dynamic Bodies.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 455)

treeMinMax :ArcadeWorldTreeMinMax

Recycled input for tree searches.

Type:
Since: 3.0.0
Source: src/physics/arcade/World.js (Line 473)

useTree :boolean

Should this Arcade Physics World use an RTree for Dynamic Physics bodies or not?

An RTree is a fast way of spatially sorting of all the moving bodies in the world.
However, at certain limits, the cost of clearing and inserting the bodies into the
tree every frame becomes more expensive than the search speed gains it provides.

If you have a large number of dynamic bodies in your world then it may be best to
disable the use of the RTree by setting this property to true.
The number it can cope with depends on browser and device, but a conservative estimate
of around 5,000 bodies should be considered the max before disabling it.

Note this only applies to dynamic bodies. Static bodies are always kept in an RTree,
because they don't have to be cleared every frame, so you benefit from the
massive search speeds all the time.

Type:
  • boolean
Since: 3.10.0
Default Value:
  • true
Source: src/physics/arcade/World.js (Line 432)

Methods


add(body)

Adds an existing Arcade Physics Body or StaticBody to the simulation.

The body is enabled and added to the local search trees.

Parameters:
Name Type Description
body Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody

The Body to be added to the simulation.

Since: 3.10.0
Source: src/physics/arcade/World.js (Line 627)
Returns:

The Body that was added to the simulation.

Type
Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody

addCollider(object1, object2 [, collideCallback] [, processCallback] [, callbackContext])

Creates a new Collider object and adds it to the simulation.

A Collider is a way to automatically perform collision checks between two objects,
calling the collide and process callbacks if they occur.

Colliders are run as part of the World update, after all of the Bodies have updated.

By creating a Collider you don't need then call World.collide in your update loop,
as it will be handled for you automatically.

Parameters:
Name Type Argument Description
object1 ArcadeColliderType

The first object to check for collision.

object2 ArcadeColliderType

The second object to check for collision.

collideCallback ArcadePhysicsCallback <optional>

The callback to invoke when the two objects collide.

processCallback ArcadePhysicsCallback <optional>

The callback to invoke when the two objects collide. Must return a boolean.

callbackContext * <optional>

The scope in which to call the callbacks.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 888)
See:
Returns:

The Collider that was created.

Type
Phaser.Physics.Arcade.Collider

addListener(event, fn [, context])

Add a listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 111)
Returns:

this.

Type
Phaser.Events.EventEmitter

addOverlap(object1, object2 [, collideCallback] [, processCallback] [, callbackContext])

Creates a new Overlap Collider object and adds it to the simulation.

A Collider is a way to automatically perform overlap checks between two objects,
calling the collide and process callbacks if they occur.

Colliders are run as part of the World update, after all of the Bodies have updated.

By creating a Collider you don't need then call World.overlap in your update loop,
as it will be handled for you automatically.

Parameters:
Name Type Argument Description
object1 ArcadeColliderType

The first object to check for overlap.

object2 ArcadeColliderType

The second object to check for overlap.

collideCallback ArcadePhysicsCallback <optional>

The callback to invoke when the two objects overlap.

processCallback ArcadePhysicsCallback <optional>

The callback to invoke when the two objects overlap. Must return a boolean.

callbackContext * <optional>

The scope in which to call the callbacks.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 924)
Returns:

The Collider that was created.

Type
Phaser.Physics.Arcade.Collider

circleBodyIntersects(circle, body)

Tests if a circular Body intersects with another Body.

Parameters:
Name Type Description
circle Phaser.Physics.Arcade.Body

The circular body to test.

body Phaser.Physics.Arcade.Body

The rectangular body to test.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1723)
Returns:

True if the two bodies intersect, otherwise false.

Type
boolean

collide(object1 [, object2] [, collideCallback] [, processCallback] [, callbackContext])

Performs a collision check and separation between the two physics enabled objects given, which can be single
Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups.

If you don't require separation then use #overlap instead.

If two Groups or arrays are passed, each member of one will be tested against each member of the other.

If one Group only is passed (as object1), each member of the Group will be collided against the other members.

Two callbacks can be provided. The collideCallback is invoked if a collision occurs and the two colliding
objects are passed to it.

Arcade Physics uses the Projection Method of collision resolution and separation. While it's fast and suitable
for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other.
The separation that stops two objects penetrating may create a new penetration against a different object. If you
require a high level of stability please consider using an alternative physics system, such as Matter.js.

Parameters:
Name Type Argument Description
object1 ArcadeColliderType

The first object or array of objects to check.

object2 ArcadeColliderType <optional>

The second object or array of objects to check, or undefined.

collideCallback ArcadePhysicsCallback <optional>

An optional callback function that is called if the objects collide.

processCallback ArcadePhysicsCallback <optional>

An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then collideCallback will only be called if this callback returns true.

callbackContext * <optional>

The context in which to run the callbacks.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1768)
Returns:

True if any overlapping Game Objects were separated, otherwise false.

Type
boolean

collideGroupVsGroup(group1, group2, collideCallback, processCallback, callbackContext, overlapOnly)

Helper for Group vs. Group collisions.

Parameters:
Name Type Description
group1 Phaser.GameObjects.Group

[description]

group2 Phaser.GameObjects.Group

[description]

collideCallback ArcadePhysicsCallback

[description]

processCallback ArcadePhysicsCallback

[description]

callbackContext *

[description]

overlapOnly boolean

Whether this is a collision or overlap check.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 2226)
Returns:

[description]

Type
boolean

collideGroupVsTilemapLayer(group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)

Helper for Group vs. Tilemap collisions.

Parameters:
Name Type Description
group Phaser.GameObjects.Group

[description]

tilemapLayer Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer

[description]

collideCallback ArcadePhysicsCallback

[description]

processCallback ArcadePhysicsCallback

[description]

callbackContext *

[description]

overlapOnly boolean

Whether this is a collision or overlap check.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 2082)
Returns:

[description]

Type
boolean

collideHandler(object1 [, object2], collideCallback, processCallback, callbackContext, overlapOnly)

Helper for Phaser.Physics.Arcade.World#collide and Phaser.Physics.Arcade.World#overlap.

Parameters:
Name Type Argument Description
object1 ArcadeColliderType

[description]

object2 ArcadeColliderType <optional>

[description]

collideCallback ArcadePhysicsCallback

[description]

processCallback ArcadePhysicsCallback

[description]

callbackContext *

[description]

overlapOnly boolean

Whether this is a collision or overlap check.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1876)
Returns:

True if any objects overlap (with overlapOnly); or true if any overlapping objects were separated.

Type
boolean

collideObjects(object1 [, object2], collideCallback, processCallback, callbackContext, overlapOnly)

Helper for Phaser.Physics.Arcade.World#collide.

Parameters:
Name Type Argument Description
object1 ArcadeColliderType

[description]

object2 ArcadeColliderType <optional>

[description]

collideCallback ArcadePhysicsCallback

[description]

processCallback ArcadePhysicsCallback

[description]

callbackContext *

[description]

overlapOnly boolean

Whether this is a collision or overlap check.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1806)
Returns:

True if any objects overlap (with overlapOnly); or true if any overlapping objects were separated.

Type
boolean

collideSpriteVsGroup(sprite, group, collideCallback, processCallback, callbackContext, overlapOnly)

Handler for Sprite vs. Group collisions.

Parameters:
Name Type Description
sprite Phaser.GameObjects.GameObject

[description]

group Phaser.GameObjects.Group

[description]

collideCallback ArcadePhysicsCallback

[description]

processCallback ArcadePhysicsCallback

[description]

callbackContext *

[description]

overlapOnly boolean

Whether this is a collision or overlap check.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1989)
Returns:

[description]

Type
boolean

collideSpriteVsSprite(sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly)

Handler for Sprite vs. Sprite collisions.

Parameters:
Name Type Description
sprite1 Phaser.GameObjects.GameObject

[description]

sprite2 Phaser.GameObjects.GameObject

[description]

collideCallback ArcadePhysicsCallback

[description]

processCallback ArcadePhysicsCallback

[description]

callbackContext *

[description]

overlapOnly boolean

Whether this is a collision or overlap check.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1954)
Returns:

[description]

Type
boolean

collideSpriteVsTilemapLayer(sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)

Helper for Sprite vs. Tilemap collisions.

Parameters:
Name Type Description
sprite Phaser.GameObjects.GameObject

[description]

tilemapLayer Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer

[description]

collideCallback ArcadePhysicsCallback

[description]

processCallback ArcadePhysicsCallback

[description]

callbackContext *

[description]

overlapOnly boolean

Whether this is a collision or overlap check.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 2122)
Fires:
Returns:

[description]

Type
boolean

computeAngularVelocity(body, delta)

Calculates a Body's angular velocity.

Parameters:
Name Type Description
body Phaser.Physics.Arcade.Body

The Body to compute the velocity for.

delta number

The delta value to be used in the calculation.

Since: 3.10.0
Source: src/physics/arcade/World.js (Line 1205)

computeVelocity(body, delta)

Calculates a Body's per-axis velocity.

Parameters:
Name Type Description
body Phaser.Physics.Arcade.Body

The Body to compute the velocity for.

delta number

The delta value to be used in the calculation.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1251)

createDebugGraphic()

Creates a Graphics Game Object that the world will use to render the debug display to.

This is called automatically when the World is instantiated if the debug config property
was set to true. However, you can call it at any point should you need to display the
debug Graphic from a fixed point.

You can control which objects are drawn to the Graphics object, and the colors they use,
by setting the debug properties in the physics config.

You should not typically use this in a production game. Use it to aid during debugging.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 755)
Returns:

The Graphics object that was created for use by the World.

Type
Phaser.GameObjects.Graphics

destroy()

Shuts down the simulation and disconnects it from the current scene.

Since: 3.0.0
Overrides:
Source: src/physics/arcade/World.js (Line 2339)

disable(object)

Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group.

The difference between this and the disableBody method is that you can pass arrays or Groups
to this method.

The body itself is not deleted, it just has its enable property set to false, which
means you can re-enable it again at any point by passing it to enable World.enable or World.add.

Parameters:
Name Type Description
object Phaser.GameObjects.GameObject | Array.<Phaser.GameObjects.GameObject> | Phaser.GameObjects.Group | Array.<Phaser.GameObjects.Group>

The object, or objects, on which to disable the bodies.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 657)

disableBody(body)

Disables an existing Arcade Physics Body or StaticBody and removes it from the simulation.

The body is disabled and removed from the local search trees.

The body itself is not deleted, it just has its enable property set to false, which
means you can re-enable it again at any point by passing it to enable World.enable or World.add.

Parameters:
Name Type Description
body Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody

The Body to be disabled.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 708)

emit(event [, args])

Calls each of the listeners registered for a given event.

Parameters:
Name Type Argument Description
event string | symbol

The event name.

args * <optional>
<repeatable>

Additional arguments that will be passed to the event handler.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 86)
Returns:

true if the event had listeners, else false.

Type
boolean

enable(object [, bodyType])

Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group.

The difference between this and the enableBody method is that you can pass arrays or Groups
to this method.

You can specify if the bodies are to be Dynamic or Static. A dynamic body can move via velocity and
acceleration. A static body remains fixed in place and as such is able to use an optimized search
tree, making it ideal for static elements such as level objects. You can still collide and overlap
with static bodies.

Normally, rather than calling this method directly, you'd use the helper methods available in the
Arcade Physics Factory, such as:

this.physics.add.image(x, y, textureKey);
this.physics.add.sprite(x, y, textureKey);

Calling factory methods encapsulates the creation of a Game Object and the creation of its
body at the same time. If you are creating custom classes then you can pass them to this
method to have their bodies created.

Parameters:
Name Type Argument Description
object Phaser.GameObjects.GameObject | Array.<Phaser.GameObjects.GameObject> | Phaser.GameObjects.Group | Array.<Phaser.GameObjects.Group>

The object, or objects, on which to create the bodies.

bodyType integer <optional>

The type of Body to create. Either DYNAMIC_BODY or STATIC_BODY.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 508)

enableBody(object [, bodyType])

Creates an Arcade Physics Body on a single Game Object.

If the Game Object already has a body, this method will simply add it back into the simulation.

You can specify if the body is Dynamic or Static. A dynamic body can move via velocity and
acceleration. A static body remains fixed in place and as such is able to use an optimized search
tree, making it ideal for static elements such as level objects. You can still collide and overlap
with static bodies.

Normally, rather than calling this method directly, you'd use the helper methods available in the
Arcade Physics Factory, such as:

this.physics.add.image(x, y, textureKey);
this.physics.add.sprite(x, y, textureKey);

Calling factory methods encapsulates the creation of a Game Object and the creation of its
body at the same time. If you are creating custom classes then you can pass them to this
method to have their bodies created.

Parameters:
Name Type Argument Description
object Phaser.GameObjects.GameObject

The Game Object on which to create the body.

bodyType integer <optional>

The type of Body to create. Either DYNAMIC_BODY or STATIC_BODY.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 576)
Returns:

The Game Object on which the body was created.

Type
Phaser.GameObjects.GameObject

eventNames()

Return an array listing the events for which the emitter has registered listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 55)
Returns:
Type
array

intersects(body1, body2)

Checks to see if two Bodies intersect at all.

Parameters:
Name Type Description
body1 Phaser.Physics.Arcade.Body

The first body to check.

body2 Phaser.Physics.Arcade.Body

The second body to check.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1675)
Returns:

True if the two bodies intersect, otherwise false.

Type
boolean

listenerCount(event)

Return the number of listeners listening to a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 75)
Returns:

The number of listeners.

Type
number

listeners(event)

Return the listeners registered for a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 64)
Returns:

The registered listeners.

Type
array

off(event, fn, context, once)

Remove the listeners of a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

fn function

Only remove the listeners that match this function.

context *

Only remove the listeners that have this context.

once boolean

Only remove one-time listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 151)
Returns:

this.

Type
Phaser.Events.EventEmitter

on(event, fn [, context])

Add a listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 98)
Returns:

this.

Type
Phaser.Events.EventEmitter

once(event, fn [, context])

Add a one-time listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 124)
Returns:

this.

Type
Phaser.Events.EventEmitter

overlap(object1 [, object2] [, overlapCallback] [, processCallback] [, callbackContext])

Tests if Game Objects overlap.

Parameters:
Name Type Argument Description
object1 ArcadeColliderType

The first object or array of objects to check.

object2 ArcadeColliderType <optional>

The second object or array of objects to check, or undefined.

overlapCallback ArcadePhysicsCallback <optional>

An optional callback function that is called if the objects overlap.

processCallback ArcadePhysicsCallback <optional>

An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then overlapCallback will only be called if this callback returns true.

callbackContext * <optional>

The context in which to run the callbacks.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1745)
Returns:

True if at least one Game Object overlaps another.

Type
boolean

pause()

Pauses the simulation.

A paused simulation does not update any existing bodies, or run any Colliders.

However, you can still enable and disable bodies within it, or manually run collide or overlap
checks.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 847)
Fires:
Returns:

This World object.

Type
Phaser.Physics.Arcade.World

postUpdate()

Updates bodies, draws the debug display, and handles pending queue operations.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1107)

remove(body)

Removes an existing Arcade Physics Body or StaticBody from the simulation.

The body is disabled and removed from the local search trees.

The body itself is not deleted, it just has its enabled property set to false, which
means you can re-enable it again at any point by passing it to enable enable or add.

Parameters:
Name Type Description
body Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody

The body to be removed from the simulation.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 728)

removeAllListeners( [event])

Remove all listeners, or those of the specified event.

Parameters:
Name Type Argument Description
event string | symbol <optional>

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 165)
Returns:

this.

Type
Phaser.Events.EventEmitter

removeCollider(collider)

Removes a Collider from the simulation so it is no longer processed.

This method does not destroy the Collider. If you wish to add it back at a later stage you can call
World.colliders.add(Collider).

If you no longer need the Collider you can call the Collider.destroy method instead, which will
automatically clear all of its references and then remove it from the World. If you call destroy on
a Collider you don't need to pass it to this method too.

Parameters:
Name Type Description
collider Phaser.Physics.Arcade.Collider

The Collider to remove from the simulation.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 959)
Returns:

This World object.

Type
Phaser.Physics.Arcade.World

removeListener(event, fn, context, once)

Remove the listeners of a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

fn function

Only remove the listeners that match this function.

context *

Only remove the listeners that have this context.

once boolean

Only remove one-time listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 137)
Returns:

this.

Type
Phaser.Events.EventEmitter

resume()

Resumes the simulation, if paused.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 870)
Fires:
Returns:

This World object.

Type
Phaser.Physics.Arcade.World

separate(body1, body2 [, processCallback] [, callbackContext] [, overlapOnly])

Separates two Bodies.

Parameters:
Name Type Argument Description
body1 Phaser.Physics.Arcade.Body

The first Body to be separated.

body2 Phaser.Physics.Arcade.Body

The second Body to be separated.

processCallback ArcadePhysicsCallback <optional>

The process callback.

callbackContext * <optional>

The context in which to invoke the callback.

overlapOnly boolean <optional>

If this a collide or overlap check?

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1360)
Fires:
Returns:

True if separation occurred, otherwise false.

Type
boolean

separateCircle(body1, body2 [, overlapOnly], bias)

Separates two Bodies, when both are circular.

Parameters:
Name Type Argument Description
body1 Phaser.Physics.Arcade.Body

The first Body to be separated.

body2 Phaser.Physics.Arcade.Body

The second Body to be separated.

overlapOnly boolean <optional>

If this a collide or overlap check?

bias number

A small value added to the calculations.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1475)
Fires:
Returns:

True if separation occurred, otherwise false.

Type
boolean

setBounds(x, y, width, height [, checkLeft] [, checkRight] [, checkUp] [, checkDown])

Sets the position, size and properties of the World boundary.

The World boundary is an invisible rectangle that defines the edges of the World.
If a Body is set to collide with the world bounds then it will automatically stop
when it reaches any of the edges. You can optionally set which edges of the boundary
should be checked against.

Parameters:
Name Type Argument Description
x number

The top-left x coordinate of the boundary.

y number

The top-left y coordinate of the boundary.

width number

The width of the boundary.

height number

The height of the boundary.

checkLeft boolean <optional>

Should bodies check against the left edge of the boundary?

checkRight boolean <optional>

Should bodies check against the right edge of the boundary?

checkUp boolean <optional>

Should bodies check against the top edge of the boundary?

checkDown boolean <optional>

Should bodies check against the bottom edge of the boundary?

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 785)
Returns:

This World object.

Type
Phaser.Physics.Arcade.World

setBoundsCollision( [left] [, right] [, up] [, down])

Enables or disables collisions on each edge of the World boundary.

Parameters:
Name Type Argument Default Description
left boolean <optional>
true

Should bodies check against the left edge of the boundary?

right boolean <optional>
true

Should bodies check against the right edge of the boundary?

up boolean <optional>
true

Should bodies check against the top edge of the boundary?

down boolean <optional>
true

Should bodies check against the bottom edge of the boundary?

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 819)
Returns:

This World object.

Type
Phaser.Physics.Arcade.World

setFPS(framerate)

Sets the frame rate to run the simulation at.

The frame rate value is used to simulate a fixed update time step. This fixed
time step allows for a straightforward implementation of a deterministic game state.

This frame rate is independent of the frequency at which the game is rendering. The
higher you set the fps, the more physics simulation steps will occur per game step.
Conversely, the lower you set it, the less will take place.

You can optionally advance the simulation directly yourself by calling the step method.

Parameters:
Name Type Description
framerate integer

The frame rate to advance the simulation at.

Since: 3.10.0
Source: src/physics/arcade/World.js (Line 983)
Returns:

This World object.

Type
Phaser.Physics.Arcade.World

shutdown()

Shuts down the simulation, clearing physics data and removing listeners.

Since: 3.0.0
Overrides:
Source: src/physics/arcade/World.js (Line 2322)

step(delta)

Advances the simulation by one step.

Parameters:
Name Type Description
delta number

The delta time amount, in ms, by which to advance the simulation.

Since: 3.10.0
Source: src/physics/arcade/World.js (Line 1048)

<protected> update(time, delta)

Advances the simulation based on the elapsed time and fps rate.

This is called automatically by your Scene and does not need to be invoked directly.

Parameters:
Name Type Description
time number

The current timestamp as generated by the Request Animation Frame or SetTimeout.

delta number

The delta time, in ms, elapsed since the last frame.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1011)

updateMotion(body, delta)

Calculates a Body's velocity and updates its position.

Parameters:
Name Type Description
body Phaser.Physics.Arcade.Body

The Body to be updated.

delta number

The delta value to be used in the motion calculations.

Since: 3.0.0
Source: src/physics/arcade/World.js (Line 1186)

wrap(object [, padding])

Wrap an object's coordinates (or several objects' coordinates) within Phaser.Physics.Arcade.World#bounds.

If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior).

Parameters:
Name Type Argument Default Description
object *

A Game Object, a Group, an object with x and y coordinates, or an array of such objects.

padding number <optional>
0

An amount added to each boundary edge during the operation.

Since: 3.3.0
Source: src/physics/arcade/World.js (Line 2256)

wrapArray(objects [, padding])

Wrap each object's coordinates within Phaser.Physics.Arcade.World#bounds.

Parameters:
Name Type Argument Default Description
objects Array.<*>

An array of objects to be wrapped.

padding number <optional>
0

An amount added to the boundary.

Since: 3.3.0
Source: src/physics/arcade/World.js (Line 2288)

wrapObject(object [, padding])

Wrap an object's coordinates within Phaser.Physics.Arcade.World#bounds.

Parameters:
Name Type Argument Default Description
object *

A Game Object, a Physics Body, or any object with x and y coordinates

padding number <optional>
0

An amount added to the boundary.

Since: 3.3.0
Source: src/physics/arcade/World.js (Line 2305)

Events


collide

Parameters:
Name Type Description
gameObject1 Phaser.GameObjects.GameObject
gameObject2 Phaser.GameObjects.GameObject
body1 Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody
body2 Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody
Source: src/physics/arcade/World.js (Line 42)

overlap

Parameters:
Name Type Description
gameObject1 Phaser.GameObjects.GameObject
gameObject2 Phaser.GameObjects.GameObject
body1 Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody
body2 Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody
Source: src/physics/arcade/World.js (Line 50)

pause

Source: src/physics/arcade/World.js (Line 34)

resume

Source: src/physics/arcade/World.js (Line 38)

worldbounds

Parameters:
Name Type Description
body Phaser.Physics.Arcade.Body
up boolean
down boolean
left boolean
right boolean
Source: src/physics/arcade/World.js (Line 58)