Phaser API Documentation

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

Description:

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

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.

Returns:
Description:

The tile X coordinate based on the world value.

Type:
  • number
Since: 3.50.0