mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 23:20:59 +00:00
Merge branch 'master' of https://github.com/photonstorm/phaser
This commit is contained in:
commit
1db68dfceb
4 changed files with 20 additions and 9 deletions
|
@ -41,7 +41,7 @@ var Tile = new Class({
|
|||
this.tint = 0xFFFFFF;
|
||||
},
|
||||
|
||||
// Copy everything except position
|
||||
// Copy everything except position & interesting faces
|
||||
copy: function (tile)
|
||||
{
|
||||
this.index = tile.index;
|
||||
|
|
|
@ -189,13 +189,13 @@ var Tilemap = new Class({
|
|||
return layer;
|
||||
},
|
||||
|
||||
copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, layer)
|
||||
copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer)
|
||||
{
|
||||
layer = this.getLayer(layer);
|
||||
if (this._isStaticCall(layer, 'copy')) { return this; }
|
||||
if (layer !== null)
|
||||
{
|
||||
TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, layer);
|
||||
TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
var GetTilesWithin = require('./GetTilesWithin');
|
||||
var CalculateFacesWithin = require('./CalculateFacesWithin');
|
||||
|
||||
// Copies indices, not other properties. Does not modify collisions.
|
||||
var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, layer)
|
||||
var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer)
|
||||
{
|
||||
if (srcTileX === undefined || srcTileX < 0) { srcTileX = 0; }
|
||||
if (srcTileY === undefined || srcTileY < 0) { srcTileY = 0; }
|
||||
if (srcTileX < 0) { srcTileX = 0; }
|
||||
if (srcTileY < 0) { srcTileY = 0; }
|
||||
if (recalculateFaces === undefined) { recalculateFaces = true; }
|
||||
|
||||
var srcTiles = GetTilesWithin(srcTileX, srcTileY, width, height, null, layer);
|
||||
|
||||
|
@ -17,9 +19,18 @@ var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, la
|
|||
var tileY = srcTiles[i].y + offsetY;
|
||||
if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height)
|
||||
{
|
||||
layer.data[tileY][tileX].index = srcTiles[i].index;
|
||||
if (layer.data[tileY][tileX])
|
||||
{
|
||||
layer.data[tileY][tileX].copy(srcTiles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (recalculateFaces)
|
||||
{
|
||||
// Recalculate the faces within the destination area and neighboring tiles
|
||||
CalculateFacesWithin(destTileX - 1, destTileY - 1, width + 2, height + 2, layer);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Copy;
|
||||
|
|
|
@ -60,9 +60,9 @@ var DynamicTilemapLayer = new Class({
|
|||
TilemapComponents.CullTiles(this.layer, camera, this.culledTiles);
|
||||
},
|
||||
|
||||
copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY)
|
||||
copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces)
|
||||
{
|
||||
TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, this.layer);
|
||||
TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer);
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue