The Tilemap.createFromTiles method has been updated. It will now copy the following properties, if set in the Tile, to the Sprites it creates: rotation, flipX, flipY, alpha, visible and tint. If these properties are declared in the spriteConfig passed to the method, those will be used instead, otherwise the Tile values are used. Fix #6711

This commit is contained in:
Richard Davey 2024-02-20 18:39:52 +00:00
parent ffc0518f2d
commit 89811d7388

View file

@ -43,6 +43,19 @@ var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, came
var sprites = [];
var i;
var mergeExtras = function (config, tile, properties)
{
for (var i = 0; i < properties.length; i++)
{
var property = properties[i];
if (!config.hasOwnProperty(property))
{
config[property] = tile[property];
}
}
};
for (i = 0; i < tiles.length; i++)
{
var tile = tiles[i];
@ -54,6 +67,8 @@ var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, came
spriteConfig.x = point.x;
spriteConfig.y = point.y;
mergeExtras(spriteConfig, tile, [ 'rotation', 'flipX', 'flipY', 'alpha', 'visible', 'tint' ]);
sprites.push(scene.make.sprite(spriteConfig));
}
}