2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
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`.
|
|
|
|
*
|
2018-02-08 01:08:59 +00:00
|
|
|
* @function Phaser.Tilemaps.Components.SetLayerCollisionIndex
|
2018-04-16 14:25:22 +00:00
|
|
|
* @private
|
2018-02-08 01:08:59 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-09-28 13:32:36 +00:00
|
|
|
* @param {integer} tileIndex - The tile index to set the collision boolean for.
|
|
|
|
* @param {boolean} [collides=true] - Should the tile index collide or not?
|
2018-02-08 02:02:37 +00:00
|
|
|
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
|
2017-11-27 13:33:30 +00:00
|
|
|
*/
|
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;
|