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

18 lines
448 B
JavaScript
Raw Normal View History

// Internal method
// Update layer.collideIndexes to either contain or not contain tileIndex
var SetLayerCollisionIndex = function (tileIndex, collides, layer)
{
var loc = layer.collideIndexes.indexOf(tileIndex);
if (collides && loc === -1)
{
layer.collideIndexes.push(tileIndex);
}
else if (!collides && loc !== -1)
{
layer.collideIndexes.splice(loc, 1);
}
};
module.exports = SetLayerCollisionIndex;