Skip to content

Commit cbaa36f

Browse files
committed
Merge pull request phaserjs#1291 from spayton/dev
Groups always had zero z index
2 parents d8d2ebd + 5b6671a commit cbaa36f

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

src/core/Group.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,24 @@ 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

56-
/**
57-
* @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.
58-
*/
59-
this.z = 0;
60-
6160
/**
6261
* @property {number} type - Internal Phaser Type value.
6362
* @protected

0 commit comments

Comments
 (0)