mirror of
https://github.com/photonstorm/phaser
synced 2024-12-23 19:43:28 +00:00
29 lines
569 B
JavaScript
29 lines
569 B
JavaScript
var IsInLayerBounds = require('./IsInLayerBounds');
|
|
|
|
var GetTileAt = function (tileX, tileY, nonNull, layer)
|
|
{
|
|
if (nonNull === undefined) { nonNull = false; }
|
|
|
|
if (IsInLayerBounds(tileX, tileY, layer))
|
|
{
|
|
var tile = layer.data[tileY][tileX];
|
|
if (tile === null)
|
|
{
|
|
return null;
|
|
}
|
|
else if (tile.index === -1)
|
|
{
|
|
return nonNull ? tile : null;
|
|
}
|
|
else
|
|
{
|
|
return tile;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
};
|
|
|
|
module.exports = GetTileAt;
|