Skip to main content
Version: Phaser v4.0.0

Phaser.Physics.Arcade.Tilemap

Scope: static

Source: src/physics/arcade/tilemap/index.js#L7

Static functions

ProcessTileCallbacks

<static> ProcessTileCallbacks(tile, sprite)

Description:

Checks whether a per-tile or per-tile-index collision callback has been registered for the given tile and, if so, invokes it with the colliding Game Object. Tile-level callbacks (set directly on the tile) take priority over layer-level callbacks (set on the tile layer by tile index). If the callback returns true the collision is vetoed and this function returns false to skip further processing of this pair. If no callback is registered, this function returns true so that normal Arcade Physics collision resolution continues.

Parameters:

nametypeoptionaldescription
tilePhaser.Tilemaps.TileNoThe Tile to process.
spritePhaser.GameObjects.SpriteNoThe Game Object to process with the Tile.

Returns: boolean - true if collision processing should continue for this tile/sprite pair, or false if a callback vetoed the collision and it should be skipped.

Source: src/physics/arcade/tilemap/ProcessTileCallbacks.js#L7
Since: 3.0.0


ProcessTileSeparationX

<static> ProcessTileSeparationX(body, x)

Description:

Internal function to process the horizontal separation of a physics body from a tile. It updates the body's left or right blocked flags based on the direction of separation, moves the body by the separation amount along the x-axis, updates its center, and then either zeroes the horizontal velocity or applies a bounce depending on the body's bounce coefficient.

Parameters:

nametypeoptionaldescription
bodyPhaser.Physics.Arcade.BodyNoThe Body object to separate.
xnumberNoThe x-axis separation distance, in pixels. A negative value indicates the body is blocked on the left; a positive value indicates it is blocked on the right.

Source: src/physics/arcade/tilemap/ProcessTileSeparationX.js#L7
Since: 3.0.0


ProcessTileSeparationY

<static> ProcessTileSeparationY(body, y)

Description:

Internal function to process the vertical separation of a physics body from a tile.

Updates the body's blocked flags based on the direction of separation, adjusts the body's vertical position by the separation amount, and then either zeroes the vertical velocity or applies the body's bounce factor to reverse it.

Parameters:

nametypeoptionaldescription
bodyPhaser.Physics.Arcade.BodyNoThe Body object to separate.
ynumberNoThe vertical separation amount, in pixels. A negative value indicates the body was blocked from above; a positive value indicates it was blocked from below.

Source: src/physics/arcade/tilemap/ProcessTileSeparationY.js#L7
Since: 3.0.0


SeparateTile

<static> SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, tileBias, isLayer)

Description:

The core separation function to separate a physics body from a tile, resolving any overlap between them. It determines which axis to process first based on the body's current velocity: if the body is moving faster horizontally the X axis is checked first, and vice versa. When moving diagonally into a tile with colliding faces on both axes, the axis of least overlap is prioritized. Separation is performed by calling TileCheckX and/or TileCheckY as appropriate, and the check short-circuits early if the first axis separation is sufficient to fully resolve the intersection.

Parameters:

nametypeoptionaldescription
inumberNoThe index of the tile within the map data.
bodyPhaser.Physics.Arcade.BodyNoThe Body object to separate.
tilePhaser.Tilemaps.TileNoThe tile to collide against.
tileWorldRectPhaser.Geom.RectangleNoA rectangle-like object defining the dimensions of the tile.
tilemapLayerPhaser.Tilemaps.TilemapLayerNoThe tilemapLayer to collide against.
tileBiasnumberNoThe tile bias value, defined by the World.TILE_BIAS constant. Used to prevent fast-moving bodies from tunneling through thin tiles.
isLayerbooleanNoIs this check coming from a TilemapLayer or an array of tiles?

Returns: boolean - true if the body was separated, otherwise false.

Source: src/physics/arcade/tilemap/SeparateTile.js#L11
Since: 3.0.0


TileCheckX

<static> TileCheckX(body, tile, tileLeft, tileRight, tileBias, isLayer)

Description:

Checks the given physics body against a tile on the X axis, calculating the overlap and applying separation if a collision is detected. Respects the tile's face and collision flags when the check originates from a TilemapLayer, and dispatches to ProcessTileSeparationX (or sets body.overlapX if customSeparateX is enabled). Used internally by the SeparateTile function.

Parameters:

nametypeoptionaldescription
bodyPhaser.Physics.Arcade.BodyNoThe Body object to separate.
tilePhaser.Tilemaps.TileNoThe tile to check.
tileLeftnumberNoThe left edge of the tile in world coordinates, in pixels.
tileRightnumberNoThe right edge of the tile in world coordinates, in pixels.
tileBiasnumberNoThe tile bias value. Overlaps greater than this threshold are ignored to prevent tunneling. Typically set to World.TILE_BIAS.
isLayerbooleanNoIs this check coming from a TilemapLayer or an array of tiles?

Returns: number - The amount of separation that occurred.

Source: src/physics/arcade/tilemap/TileCheckX.js#L9
Since: 3.0.0


TileCheckY

<static> TileCheckY(body, tile, tileTop, tileBottom, tileBias, isLayer)

Description:

Checks for overlap between a physics body and a tile along the Y axis and resolves any collision that is found. If the body has a custom separator set, the overlap value is stored on body.overlapY for the caller to handle; otherwise ProcessTileSeparationY is called to resolve the collision immediately. Used internally by the SeparateTile function.

Parameters:

nametypeoptionaldescription
bodyPhaser.Physics.Arcade.BodyNoThe Body object to separate.
tilePhaser.Tilemaps.TileNoThe tile to check.
tileTopnumberNoThe top position of the tile in world space, in pixels.
tileBottomnumberNoThe bottom position of the tile in world space, in pixels.
tileBiasnumberNoThe tile bias value, as defined by the World.TILE_BIAS constant.
isLayerbooleanNoIs this check coming from a TilemapLayer or an array of tiles?

Returns: number - The amount of vertical separation that occurred, in pixels.

Source: src/physics/arcade/tilemap/TileCheckY.js#L9
Since: 3.0.0


TileIntersectsBody

<static> TileIntersectsBody(tileWorldRect, body)

Description:

Checks for intersection between the given tile rectangle-like object and an Arcade Physics body.

Parameters:

nametypeoptionaldescription
tileWorldRectObjectNoA rectangle object that defines the tile placement in the world.
bodyPhaser.Physics.Arcade.BodyNoThe body to check for intersection against.

Returns: boolean - Returns true if the tile intersects with the body, otherwise false.

Source: src/physics/arcade/tilemap/TileIntersectsBody.js#L7
Since: 3.0.0