From 5f6fc9db05acbda20b544bbffa8fbda7745b4b7f Mon Sep 17 00:00:00 2001 From: photonstorm Date: Fri, 21 Feb 2014 12:33:15 +0000 Subject: [PATCH] When adding a Group if the parent value is null the Group won't be added to the World, so it's up to you to add it when ready. If parent is undefined it's added to World. --- src/core/Group.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/core/Group.js b/src/core/Group.js index e4b0530c..87ae200c 100644 --- a/src/core/Group.js +++ b/src/core/Group.js @@ -10,18 +10,20 @@ * @classdesc A Group is a container for display objects that allows for fast pooling and object recycling. Groups can be nested within other Groups and have their own local transforms. * @constructor * @param {Phaser.Game} game - A reference to the currently running game. -* @param {Phaser.Group|Phaser.Sprite} parent - The parent Group, DisplayObject or DisplayObjectContainer that this Group will be added to. If undefined or null it will use game.world. +* @param {Phaser.Group|Phaser.Sprite|null} parent - The parent Group, DisplayObject or DisplayObjectContainer that this Group will be added to. If undefined it will use game.world. If null it won't be added to anything. * @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging. * @param {boolean} [addToStage=false] - If set to true this Group will be added directly to the Game.Stage instead of Game.World. */ Phaser.Group = function (game, parent, name, addToStage) { + if (typeof addToStage === 'undefined') { addToStage = false; } + /** * @property {Phaser.Game} game - A reference to the currently running Game. */ this.game = game; - if (typeof parent === 'undefined' || parent === null) + if (typeof parent === 'undefined') { parent = game.world; } @@ -33,20 +35,16 @@ Phaser.Group = function (game, parent, name, addToStage) { PIXI.DisplayObjectContainer.call(this); - if (typeof addToStage === 'undefined' || addToStage === false) + if (addToStage) + { + this.game.stage.addChild(this); + } + else { if (parent) { parent.addChild(this); } - else - { - this.game.stage.addChild(this); - } - } - else - { - this.game.stage.addChild(this); } /**