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

30 lines
569 B
JavaScript
Raw Normal View History

2017-11-16 19:09:07 +00:00
var IsInLayerBounds = require('./IsInLayerBounds');
var GetTileAt = function (tileX, tileY, nonNull, layer)
{
if (nonNull === undefined) { nonNull = false; }
2017-11-16 19:09:07 +00:00
if (IsInLayerBounds(tileX, tileY, layer))
{
var tile = layer.data[tileY][tileX];
2017-11-16 19:09:07 +00:00
if (tile === null)
{
return null;
}
else if (tile.index === -1)
{
return nonNull ? tile : null;
}
else
{
return tile;
}
}
else
{
return null;
}
};
module.exports = GetTileAt;