Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/tilemaps/Tilemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down
1 change: 1 addition & 0 deletions src/tilemaps/typedefs/CreateFromObjectLayerConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/