mirror of
https://github.com/photonstorm/phaser
synced 2024-11-16 17:58:23 +00:00
Update CreateGroupLayer.js
This commit is contained in:
parent
96203aac19
commit
bdbadd1339
1 changed files with 12 additions and 13 deletions
|
@ -13,20 +13,19 @@ var GetFastValue = require('../../../utils/object/GetFastValue');
|
|||
* @since 3.21.0
|
||||
*
|
||||
* @param {object} json - The Tiled JSON object.
|
||||
* @param {object} [currentl] - The current group layer from the Tiled JSON file.
|
||||
* @param {object} [parentstate] - The state of the parent group (if any).
|
||||
* @param {object} [group] - The current group layer from the Tiled JSON file.
|
||||
* @param {object} [parentState] - The state of the parent group (if any).
|
||||
*
|
||||
* @return {object} A group state object with proper values for updating children layers.
|
||||
*/
|
||||
var CreateGroupLayer = function (json, groupl, parentstate)
|
||||
var CreateGroupLayer = function (json, group, parentState)
|
||||
{
|
||||
if (!groupl)
|
||||
if (!group)
|
||||
{
|
||||
// Return a default group state object
|
||||
return {
|
||||
i: 0, // Current layer array iterator
|
||||
layers: json.layers, // Current array of layers
|
||||
|
||||
// Values inherited from parent group
|
||||
name: '',
|
||||
opacity: 1,
|
||||
|
@ -37,18 +36,18 @@ var CreateGroupLayer = function (json, groupl, parentstate)
|
|||
}
|
||||
|
||||
// Compute group layer x, y
|
||||
var layerX = groupl.x + GetFastValue(groupl, 'startx', 0) * json.tilewidth + GetFastValue(groupl, 'offsetx', 0);
|
||||
var layerY = groupl.y + GetFastValue(groupl, 'starty', 0) * json.tileheight + GetFastValue(groupl, 'offsety', 0);
|
||||
var layerX = group.x + GetFastValue(group, 'startx', 0) * json.tilewidth + GetFastValue(group, 'offsetx', 0);
|
||||
var layerY = group.y + GetFastValue(group, 'starty', 0) * json.tileheight + GetFastValue(group, 'offsety', 0);
|
||||
|
||||
// Compute next state inherited from group
|
||||
return {
|
||||
i: 0,
|
||||
layers: groupl.layers,
|
||||
name: parentstate.name + groupl.name + '/',
|
||||
opacity: parentstate.opacity * groupl.opacity,
|
||||
visible: parentstate.visible && groupl.visible,
|
||||
x: parentstate.x + layerX,
|
||||
y: parentstate.y + layerY
|
||||
layers: group.layers,
|
||||
name: parentState.name + group.name + '/',
|
||||
opacity: parentState.opacity * group.opacity,
|
||||
visible: parentState.visible && group.visible,
|
||||
x: parentState.x + layerX,
|
||||
y: parentState.y + layerY
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue