mirror of
https://github.com/photonstorm/phaser
synced 2024-12-23 19:43:28 +00:00
23 lines
661 B
JavaScript
23 lines
661 B
JavaScript
var GetTilesWithin = require('./GetTilesWithin');
|
|
|
|
// Swaps indices, not other properties. Does not modify collisions. Matches v2 functionality.
|
|
var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer)
|
|
{
|
|
var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer);
|
|
for (var i = 0; i < tiles.length; i++)
|
|
{
|
|
if (tiles[i])
|
|
{
|
|
if (tiles[i].index === indexA)
|
|
{
|
|
tiles[i].index = indexB;
|
|
}
|
|
else if (tiles[i].index === indexB)
|
|
{
|
|
tiles[i].index = indexA;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = SwapByIndex;
|