phaser/v3/src/gameobjects/tilemap/components/GetTileAtWorldXY.js

16 lines
509 B
JavaScript
Raw Normal View History

2017-11-16 19:27:52 +00:00
var GetTileAt = require('./GetTileAt');
var SnapFloor = require('../../../math/snap/SnapFloor');
// NOTE: phaser v2 version doesn't account for TilemapLayer's XY, so neither does this version
// currently.
var GetTileAtWorldXY = function (worldX, worldY, nonNull, layer)
{
var tileX = SnapFloor(worldX, layer.tileWidth) / layer.tileWidth;
var tileY = SnapFloor(worldY, layer.tileHeight) / layer.tileHeight;
return GetTileAt(tileX, tileY, nonNull, layer);
};
module.exports = GetTileAtWorldXY;