Phaser API Documentation

  Version: 
worldToTileXY(worldX, worldY, [snapToFloor], [point], [camera])

Description:

Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the layers position, scale and scroll. This will return a new Vector2 object or update the given point object.

Parameters:

name type arguments description
worldX number

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

worldY number

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

snapToFloor boolean <optional>

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

point Phaser.Math.Vector2 <optional>

A Vector2 to store the coordinates in. If not given a new Vector2 is created.

camera Phaser.Cameras.Scene2D.Camera <optional>

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

Returns:
Description:

A Vector2 containing the tile coordinates of the world values.

Since: 3.50.0