Skip to content

Commit 3da69ad

Browse files
committed
Tilemap.createDynamicLayer would fail if you called it without setting the x and y arguments, even though they were flagged as being optional. Fix phaserjs#4508
1 parent 04ec7b2 commit 3da69ad

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ The following changes took place in the Pointer class:
123123
* Changing the `radius` of an Arc Game Object wouldn't update the size, causing origin issues. It now updates the size and origin correctly in WebGL. Fix #4542 (thanks @@PhaserEditor2D)
124124
* Setting `padding` in a Text style configuration object would cause an error about calling split on undefined. Padding can now be applied both in the config and via `setPadding`.
125125
* `Tilemap.createBlankDynamicLayer` would fail if you provided a string for the tileset as the base tile width and height were incorrectly read from the tileset argument. Fix #4495 (thanks @jppresents)
126+
* `Tilemap.createDynamicLayer` would fail if you called it without setting the `x` and `y` arguments, even though they were flagged as being optional. Fix #4508 (thanks @jackfreak)
126127

127128
### Examples, Documentation and TypeScript
128129

src/tilemaps/Tilemap.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,16 @@ var Tilemap = new Class({
561561
this.currentLayerIndex = index;
562562

563563
// Default the x/y position to match Tiled layer offset, if it exists.
564-
if (x === undefined && this.layers[index].x) { x = this.layers[index].x; }
565-
if (y === undefined && this.layers[index].y) { y = this.layers[index].y; }
564+
565+
if (x === undefined)
566+
{
567+
x = layerData.x;
568+
}
569+
570+
if (y === undefined)
571+
{
572+
y = layerData.y;
573+
}
566574

567575
var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y);
568576

0 commit comments

Comments
 (0)