* Convert world coordinates to tile coordinates * 将世界坐标转换为图块坐标 * @returns [col, row] | [列, 行]
(worldX: number, worldY: number)
| 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) |