2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2018-02-12 16:01:20 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2018-02-07 17:10:01 +00:00
|
|
|
var GetFastValue = require('../../../utils/object/GetFastValue');
|
2017-12-01 19:24:37 +00:00
|
|
|
|
2018-02-10 01:50:48 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @function Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {object} json - [description]
|
|
|
|
*
|
|
|
|
* @return {array} [description]
|
|
|
|
*/
|
2017-12-01 19:24:37 +00:00
|
|
|
var ParseImageLayers = function (json)
|
|
|
|
{
|
|
|
|
var images = [];
|
|
|
|
|
|
|
|
for (var i = 0; i < json.layers.length; i++)
|
|
|
|
{
|
|
|
|
if (json.layers[i].type !== 'imagelayer')
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var curi = json.layers[i];
|
|
|
|
|
|
|
|
images.push({
|
|
|
|
name: curi.name,
|
|
|
|
image: curi.image,
|
|
|
|
x: GetFastValue(curi, 'offsetx', 0) + curi.x,
|
|
|
|
y: GetFastValue(curi, 'offsety', 0) + curi.y,
|
|
|
|
alpha: curi.opacity,
|
|
|
|
visible: curi.visible,
|
|
|
|
properties: GetFastValue(curi, 'properties', {})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return images;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = ParseImageLayers;
|