Phaser API Documentation

  Version: 
worldToTileX(worldX, [snapToFloor], [camera], [layer])

Description:

Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the layers position, scale and scroll.

If no layer is specified, the maps current layer is used.

Parameters:

name type arguments description
worldX number

The x coordinate to be converted, in pixels, not tiles.

snapToFloor boolean <optional>

Whether or not to round the tile coordinate down to the nearest integer.

camera Phaser.Cameras.Scene2D.Camera <optional>

The Camera to use when calculating the tile index from the world values.

layer string | number | Phaser.Tilemaps.TilemapLayer <optional>

The tile layer to use. If not given the current layer is used.

Returns:
Description:

Returns a number, or null if the layer given was invalid.

Type:
  • number
Since: 3.0.0
Source: src/tilemaps/Tilemap.js (Line 2528)