MCPcopy Create free account
hub / github.com/esengine/esengine / worldToTile

Method worldToTile

packages/tilemap/src/TilemapComponent.ts:969–973  ·  view source on GitHub ↗

* Convert world coordinates to tile coordinates * 将世界坐标转换为图块坐标 * @returns [col, row] | [列, 行]

(worldX: number, worldY: number)

Source from the content-addressed store, hash-verified

967 * @returns [col, row] | [列, 行]
968 */
969 worldToTile(worldX: number, worldY: number): [number, number] {
970 const col = Math.floor(worldX / this.tileWidth);
971 const row = Math.floor(worldY / this.tileHeight);
972 return [col, row];
973 }
974
975 /**
976 * Convert tile coordinates to world coordinates (center of tile)

Callers 1

hasCollisionAtMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected