Class: World

Phaser.Physics.Impact. World

[description]


new World(scene, config)

Parameters:
Name Type Description
scene Phaser.Scene

The Scene to which this Impact World instance belongs.

config Phaser.Types.Physics.Impact.WorldConfig

[description]

Since: 3.0.0
Source: src/physics/impact/World.js (Line 20)

Extends

Members


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

[description]

Type:
Since: 3.0.0
Source: src/physics/impact/World.js (Line 52)

cellSize :integer

Spatial hash cell dimensions

Type:
  • integer
Since: 3.0.0
Default Value:
  • 64
Source: src/physics/impact/World.js (Line 71)

collisionMap :Phaser.Physics.Impact.CollisionMap

[description]

Type:
Since: 3.0.0
Source: src/physics/impact/World.js (Line 81)

debugGraphic :Phaser.GameObjects.Graphics

[description]

Type:
Since: 3.0.0
Source: src/physics/impact/World.js (Line 129)

defaults :Phaser.Types.Physics.Impact.WorldDefaults

[description]

Type:
Since: 3.0.0
Source: src/physics/impact/World.js (Line 140)

delta :number

[description]

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/impact/World.js (Line 168)

drawDebug :boolean

[description]

Type:
  • boolean
Since: 3.0.0
Source: src/physics/impact/World.js (Line 120)

enabled :boolean

[description]

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/physics/impact/World.js (Line 110)

gravity :number

[description]

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/physics/impact/World.js (Line 61)

maxStep :number

Impacts maximum time step is 20 fps.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0.05
Source: src/physics/impact/World.js (Line 100)

scene :Phaser.Scene

[description]

Type:
Since: 3.0.0
Source: src/physics/impact/World.js (Line 43)

timeScale :number

[description]

Type:
  • number
Since: 3.0.0
Default Value:
  • 1
Source: src/physics/impact/World.js (Line 90)

walls :Phaser.Types.Physics.Impact.WorldWalls

An object containing the 4 wall bodies that bound the physics world.

Type:
Since: 3.0.0
Source: src/physics/impact/World.js (Line 159)

Methods


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

checkBodies(bodyA, bodyB)

[description]

Parameters:
Name Type Description
bodyA Phaser.Physics.Impact.Body

[description]

bodyB Phaser.Physics.Impact.Body

[description]

Since: 3.0.0
Source: src/physics/impact/World.js (Line 651)

checkHash(body, hash, size)

Check the body against the spatial hash.

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

[description]

hash object

[description]

size number

[description]

Since: 3.0.0
Source: src/physics/impact/World.js (Line 599)

create(x, y, sizeX, sizeY)

[description]

Parameters:
Name Type Description
x number

[description]

y number

[description]

sizeX number

[description]

sizeY number

[description]

Since: 3.0.0
Source: src/physics/impact/World.js (Line 457)
Returns:

The Body that was added to this World.

Type
Phaser.Physics.Impact.Body

createDebugGraphic()

Creates a Graphics Game Object used for debug display and enables the world for debug drawing.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 423)
Returns:

The Graphics object created that will have the debug visuals drawn to it.

Type
Phaser.GameObjects.Graphics

destroy()

[description]

Since: 3.0.0
Overrides:
Source: src/physics/impact/World.js (Line 958)

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

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

getNextID()

[description]

Since: 3.0.0
Source: src/physics/impact/World.js (Line 444)
Returns:

[description]

Type
integer

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 Argument Description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

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

pause()

[description]

Since: 3.0.0
Source: src/physics/impact/World.js (Line 492)
Fires:
Returns:

This World object.

Type
Phaser.Physics.Impact.World

remove(object)

[description]

Parameters:
Name Type Description
object Phaser.Physics.Impact.Body

The Body to remove from this World.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 479)

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

removeListener(event [, fn] [, context] [, once])

Remove the listeners of a given event.

Parameters:
Name Type Argument Description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

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()

[description]

Since: 3.0.0
Source: src/physics/impact/World.js (Line 510)
Fires:
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setActive(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the collides value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 745)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setAvsB(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the type value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 845)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setBounds( [x] [, y] [, width] [, height] [, thickness] [, left] [, right] [, top] [, bottom])

Sets the bounds of the Physics world to match the given world pixel dimensions. You can optionally set which 'walls' to create: left, right, top or bottom. If none of the walls are given it will default to use the walls settings it had previously. I.e. if you previously told it to not have the left or right walls, and you then adjust the world size the newly created bounds will also not have the left and right walls. Explicitly state them in the parameters to override this.

Parameters:
Name Type Argument Default Description
x number <optional>

The x coordinate of the top-left corner of the bounds.

y number <optional>

The y coordinate of the top-left corner of the bounds.

width number <optional>

The width of the bounds.

height number <optional>

The height of the bounds.

thickness number <optional>
64

[description]

left boolean <optional>
true

If true will create the left bounds wall.

right boolean <optional>
true

If true will create the right bounds wall.

top boolean <optional>
true

If true will create the top bounds wall.

bottom boolean <optional>
true

If true will create the bottom bounds wall.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 338)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setBvsA(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the type value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 866)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setCheckAgainstA(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the type value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 907)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setCheckAgainstB(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the type value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 927)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setCheckAgainstNone(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the type value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 887)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setCollidesNever(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the collides value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 685)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setCollisionMap(key, tileSize)

Sets the collision map for the world either from a Weltmeister JSON level in the cache or from a 2D array. If loading from a Weltmeister level, the map must have a layer called "collision".

Parameters:
Name Type Description
key string | Array.<Array.<integer>>

Either a string key that corresponds to a Weltmeister level in the cache, or a 2D array of collision IDs.

tileSize integer

The size of a tile. This is optional if loading from a Weltmeister level in the cache.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 219)
Returns:

The newly created CollisionMap, or null if the method failed to create the CollisionMap.

Type
Phaser.Physics.Impact.CollisionMap

setCollisionMapFromTilemapLayer(tilemapLayer [, options])

Sets the collision map for the world from a tilemap layer. Only tiles that are marked as colliding will be used. You can specify the mapping from tiles to slope IDs in a couple of ways. The easiest is to use Tiled and the slopeTileProperty option. Alternatively, you can manually create a slopeMap that stores the mapping between tile indices and slope IDs.

Parameters:
Name Type Argument Description
tilemapLayer Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer

The tilemap layer to use.

options Phaser.Types.Physics.Impact.CollisionOptions <optional>

Options for controlling the mapping from tiles to slope IDs.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 273)
Returns:

The newly created CollisionMap.

Type
Phaser.Physics.Impact.CollisionMap

setFixed(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the collides value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 765)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setLite(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the collides value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 705)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setPassive(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the collides value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 725)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setTypeA(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the type value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 805)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setTypeB(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the type value on.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 825)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

setTypeNone(bodies)

[description]

Parameters:
Name Type Description
bodies Array.<Phaser.Physics.Impact.Body>

An Array of Impact Bodies to set the type value on.

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

This World object.

Type
Phaser.Physics.Impact.World

shutdown()

[description]

Since: 3.0.0
Overrides:
Source: src/physics/impact/World.js (Line 947)

update(time, delta)

[description]

Parameters:
Name Type Description
time number

The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.

delta number

The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 528)

updateWall(add, position, x, y, width, height)

position = 'left', 'right', 'top' or 'bottom'

Parameters:
Name Type Description
add boolean

[description]

position string

[description]

x number

[description]

y number

[description]

width number

[description]

height number

[description]

Since: 3.0.0
Source: src/physics/impact/World.js (Line 381)