Class: World

Phaser.Physics.Impact. World

[description]


new World(scene, config)

Parameters:
Name Type Description
scene Phaser.Scene

[description]

config Phaser.Physics.Impact.WorldConfig

[description]

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

Extends

Members


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

[description]

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

cellSize :integer

Spatial hash cell dimensions

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

collisionMap :Phaser.Physics.Impact.CollisionMap

[description]

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

debugGraphic :Phaser.GameObjects.Graphics

[description]

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

defaults :Phaser.Physics.Impact.WorldDefaults

[description]

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

delta :number

[description]

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

drawDebug :boolean

[description]

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

enabled :boolean

[description]

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

gravity :number

[description]

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

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

scene :Phaser.Scene

[description]

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

timeScale :number

[description]

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

walls :Phaser.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 213)

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

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

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 520)
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 486)
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 1019)

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

pause()

[description]

Since: 3.0.0
Source: src/physics/impact/World.js (Line 555)
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 542)

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

[description]

Since: 3.0.0
Source: src/physics/impact/World.js (Line 572)
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 806)
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 906)
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 401)
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 927)
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 968)
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 988)
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 948)
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 746)
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 273)
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 object <optional>

Options for controlling the mapping from tiles to slope IDs.

Properties
Name Type Argument Default Description
slopeTileProperty string <optional>
null

Slope IDs can be stored on tiles directly
using Tiled's tileset editor. If a tile has a property with the given slopeTileProperty string
name, the value of that property for the tile will be used for its slope mapping. E.g. a 45
degree slope upward could be given a "slope" property with a value of 2.

slopeMap object <optional>
null

A tile index to slope definition map.

defaultCollidingSlope integer <optional>
null

If specified, the default slope ID to
assign to a colliding tile. If not specified, the tile's index is used.

defaultNonCollidingSlope integer <optional>
0

The default slope ID to assign to a
non-colliding tile.

Since: 3.0.0
Source: src/physics/impact/World.js (Line 327)
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 826)
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 766)
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 786)
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 866)
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 886)
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 846)
Returns:

This World object.

Type
Phaser.Physics.Impact.World

shutdown()

[description]

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

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

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