2017-11-27 13:33:30 +00:00
|
|
|
/**
|
|
|
|
* Internally used method to keep track of the tile indexes that collide within a layer. This
|
|
|
|
* updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`.
|
|
|
|
*
|
|
|
|
* @param {number} tileIndex - [description]
|
|
|
|
* @param {boolean} [collides=true] - [description]
|
|
|
|
* @param {LayerData} layer - [description]
|
|
|
|
*/
|
2017-11-22 01:13:43 +00:00
|
|
|
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;
|