Skip to content

Commit b7ca32e

Browse files
committed
Copy custom properties in createFromObjects()
Closes phaserjs#3808
1 parent a02d5ff commit b7ca32e

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/tilemaps/Tilemap.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,9 @@ var Tilemap = new Class({
501501
* way to configure Sprite properties from within the map editor. For example giving an object a
502502
* property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created.
503503
*
504+
* Custom object properties not sharing names with the Sprite's own properties are copied to the
505+
* Sprite's {@link Phaser.GameObjects.Sprite#data data store}.
506+
*
504507
* @method Phaser.Tilemaps.Tilemap#createFromObjects
505508
* @since 3.0.0
506509
*
@@ -579,6 +582,16 @@ var Tilemap = new Class({
579582

580583
if (!obj.visible) { sprite.visible = false; }
581584

585+
for (var key in obj.properties)
586+
{
587+
if (sprite.hasOwnProperty(key))
588+
{
589+
continue;
590+
}
591+
592+
sprite.setData(key, obj.properties[key]);
593+
}
594+
582595
sprites.push(sprite);
583596
}
584597
}

0 commit comments

Comments
 (0)