Skip to content

Commit 0012ed3

Browse files
committed
Added Tilemap.renderDebugFull method.
1 parent 95cf972 commit 0012ed3

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Notes:
6666
* `GameObjects.Components.PathFollower` is a new component that manages any type of Game Object following a path. The original Path Follower Game Object has been updated to use this new component directly, but it can be applied to any custom Game Object class.
6767
* `Tilemap.removeLayer` is a new method that allows you to remove a specific layer from a Tilemap without destroying it.
6868
* `Tilemap.destroyLayer` is a new method that allows you to destroy a layer and remove it from a Tilemap.
69+
* `Tilemap.renderDebugFull` is a new method that will debug render all layers in the Tilemap to the given Graphics object.
6970

7071
### Updates
7172

src/tilemaps/Tilemap.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,35 @@ var Tilemap = new Class({
17641764
return this;
17651765
},
17661766

1767+
/**
1768+
* Draws a debug representation of all layers within this Tilemap to the given Graphics object.
1769+
*
1770+
* This is helpful when you want to get a quick idea of which of your tiles are colliding and which
1771+
* have interesting faces. The tiles are drawn starting at (0, 0) in the Graphics, allowing you to
1772+
* place the debug representation wherever you want on the screen.
1773+
*
1774+
* @method Phaser.Tilemaps.Tilemap#renderDebugFull
1775+
* @since 3.17.0
1776+
*
1777+
* @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon.
1778+
* @param {Phaser.Tilemaps.Types.StyleConfig} styleConfig - An object specifying the colors to use for the debug drawing.
1779+
* @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used.
1780+
*
1781+
* @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid.
1782+
*/
1783+
renderDebugFull: function (graphics, styleConfig)
1784+
{
1785+
var layers = this.layers;
1786+
1787+
// Destroy any StaticTilemapLayers or DynamicTilemapLayers that are stored in LayerData
1788+
for (var i = 0; i < layers.length; i++)
1789+
{
1790+
TilemapComponents.RenderDebug(graphics, styleConfig, layers[i]);
1791+
}
1792+
1793+
return this;
1794+
},
1795+
17671796
/**
17681797
* Scans the given rectangular area (given in tile coordinates) for tiles with an index matching
17691798
* `findIndex` and updates their index to match `newIndex`. This only modifies the index and does

0 commit comments

Comments
 (0)