Skip to content

Commit b51c162

Browse files
author
spayton
committed
Fixed new groups incorrectly always adding with a z index of 0
1 parent be8499f commit b51c162

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/core/Group.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,21 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
3939
*/
4040
this.name = name || 'group';
4141

42+
/**
43+
* @property {number} z - The z-depth value of this object within its Group (remember the World is a Group as well). No two objects in a Group can have the same z value.
44+
*/
45+
this.z = 0;
46+
4247
PIXI.DisplayObjectContainer.call(this);
4348

44-
if (addToStage)
45-
{
49+
if (addToStage) {
4650
this.game.stage.addChild(this);
51+
this.z = this.game.stage.children.length;
4752
}
48-
else
49-
{
50-
if (parent)
51-
{
53+
else {
54+
if (parent) {
5255
parent.addChild(this);
56+
this.z = parent.children.length;
5357
}
5458
}
5559

0 commit comments

Comments
 (0)