Phaser.Physics.Arcade.Tilemap
Scope: static
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:
| name | type | optional | description |
|---|---|---|---|
| tile | Phaser.Tilemaps.Tile | No | The Tile to process. |
| sprite | Phaser.GameObjects.Sprite | No | The 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:
| name | type | optional | description |
|---|---|---|---|
| body | Phaser.Physics.Arcade.Body | No | The Body object to separate. |
| x | number | No | The 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:
| name | type | optional | description |
|---|---|---|---|
| body | Phaser.Physics.Arcade.Body | No | The Body object to separate. |
| y | number | No | The 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:
| name | type | optional | description |
|---|---|---|---|
| i | number | No | The index of the tile within the map data. |
| body | Phaser.Physics.Arcade.Body | No | The Body object to separate. |
| tile | Phaser.Tilemaps.Tile | No | The tile to collide against. |
| tileWorldRect | Phaser.Geom.Rectangle | No | A rectangle-like object defining the dimensions of the tile. |
| tilemapLayer | Phaser.Tilemaps.TilemapLayer | No | The tilemapLayer to collide against. |
| tileBias | number | No | The tile bias value, defined by the World.TILE_BIAS constant. Used to prevent fast-moving bodies from tunneling through thin tiles. |
| isLayer | boolean | No | Is 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:
| name | type | optional | description |
|---|---|---|---|
| body | Phaser.Physics.Arcade.Body | No | The Body object to separate. |
| tile | Phaser.Tilemaps.Tile | No | The tile to check. |
| tileLeft | number | No | The left edge of the tile in world coordinates, in pixels. |
| tileRight | number | No | The right edge of the tile in world coordinates, in pixels. |
| tileBias | number | No | The tile bias value. Overlaps greater than this threshold are ignored to prevent tunneling. Typically set to World.TILE_BIAS. |
| isLayer | boolean | No | Is 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:
| name | type | optional | description |
|---|---|---|---|
| body | Phaser.Physics.Arcade.Body | No | The Body object to separate. |
| tile | Phaser.Tilemaps.Tile | No | The tile to check. |
| tileTop | number | No | The top position of the tile in world space, in pixels. |
| tileBottom | number | No | The bottom position of the tile in world space, in pixels. |
| tileBias | number | No | The tile bias value, as defined by the World.TILE_BIAS constant. |
| isLayer | boolean | No | Is 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:
| name | type | optional | description |
|---|---|---|---|
| tileWorldRect | Object | No | A rectangle object that defines the tile placement in the world. |
| body | Phaser.Physics.Arcade.Body | No | The 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