From a86daa07323cbbcf41d1f3b8e3b1ff1a5e1b02cd Mon Sep 17 00:00:00 2001 From: Florian <32780344+saintflow47@users.noreply.github.com> Date: Tue, 22 Jul 2025 13:11:00 +0200 Subject: [PATCH 1/2] Update Tilemap.js createFromObjects with sort by config.sortByY --- src/tilemaps/Tilemap.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tilemaps/Tilemap.js b/src/tilemaps/Tilemap.js index 5969fadae1..0ffd5d7385 100644 --- a/src/tilemaps/Tilemap.js +++ b/src/tilemaps/Tilemap.js @@ -818,6 +818,11 @@ var Tilemap = new Class({ var objects = objectLayer.objects; + if (config.sortByY)) + { + objects.sort((a,b) => a.y > b.y ? 1 : -1) + } + for (var c = 0; c < config.length; c++) { var singleConfig = config[ c ]; From afc09969840865039ddbbcf5248dc09cd8db254a Mon Sep 17 00:00:00 2001 From: Florian <32780344+saintflow47@users.noreply.github.com> Date: Tue, 22 Jul 2025 13:19:45 +0200 Subject: [PATCH 2/2] Update CreateFromObjectLayerConfig.js with new optional sortByY param --- src/tilemaps/typedefs/CreateFromObjectLayerConfig.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tilemaps/typedefs/CreateFromObjectLayerConfig.js b/src/tilemaps/typedefs/CreateFromObjectLayerConfig.js index d48bf63df5..e70a310a26 100644 --- a/src/tilemaps/typedefs/CreateFromObjectLayerConfig.js +++ b/src/tilemaps/typedefs/CreateFromObjectLayerConfig.js @@ -12,4 +12,5 @@ * @property {Phaser.GameObjects.Container} [container] - Optional Container to which the Game Objects are added. * @property {(string|Phaser.Textures.Texture)} [key] - Optional key of a Texture to be used, as stored in the Texture Manager, or a Texture instance. If omitted, the object's gid's tileset key is used if available. * @property {(string|number)} [frame] - Optional name or index of the frame within the Texture. If omitted, the tileset index is used, assuming that spritesheet frames exactly match tileset indices & geometries -- if available. + * @property {boolean} [sortByY=false] - Sort objects in layer by their y position. Objects with a higher y are displayed above objects with a lower y. */