mirror of
https://github.com/photonstorm/phaser
synced 2025-02-25 11:57:19 +00:00
Group methods now have optional addToScene
and removeFromScene
arguments
#3080
This commit is contained in:
parent
7c2bd98e44
commit
37713b9f4a
1 changed files with 55 additions and 12 deletions
|
@ -216,8 +216,10 @@ var Group = new Class({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
add: function (child)
|
add: function (child, addToScene)
|
||||||
{
|
{
|
||||||
|
if (addToScene === undefined) { addToScene = false; }
|
||||||
|
|
||||||
this.children.set(child);
|
this.children.set(child);
|
||||||
|
|
||||||
if (this.createCallback)
|
if (this.createCallback)
|
||||||
|
@ -225,31 +227,72 @@ var Group = new Class({
|
||||||
this.createCallback.call(this, child);
|
this.createCallback.call(this, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
if (addToScene)
|
||||||
},
|
|
||||||
|
|
||||||
addMultiple: function (children)
|
|
||||||
{
|
|
||||||
if (Array.isArray(children))
|
|
||||||
{
|
{
|
||||||
for (var i = 0; i < children.length; i++)
|
this.scene.sys.displayList.add(child);
|
||||||
|
|
||||||
|
if (child.preUpdate)
|
||||||
{
|
{
|
||||||
this.add(children[i]);
|
this.scene.sys.updateList.add(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
remove: function (child)
|
addMultiple: function (children, addToScene)
|
||||||
{
|
{
|
||||||
this.children.delete(child);
|
if (addToScene === undefined) { addToScene = false; }
|
||||||
|
|
||||||
|
if (Array.isArray(children))
|
||||||
|
{
|
||||||
|
for (var i = 0; i < children.length; i++)
|
||||||
|
{
|
||||||
|
this.add(children[i], addToScene);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function ()
|
remove: function (child, removeFromScene)
|
||||||
{
|
{
|
||||||
|
if (removeFromScene === undefined) { removeFromScene = false; }
|
||||||
|
|
||||||
|
this.children.delete(child);
|
||||||
|
|
||||||
|
if (removeFromScene)
|
||||||
|
{
|
||||||
|
this.scene.sys.displayList.remove(child);
|
||||||
|
|
||||||
|
if (child.preUpdate)
|
||||||
|
{
|
||||||
|
this.scene.sys.updateList.remove(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
clear: function (removeFromScene)
|
||||||
|
{
|
||||||
|
if (removeFromScene === undefined) { removeFromScene = false; }
|
||||||
|
|
||||||
|
if (removeFromScene)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < children.length; i++)
|
||||||
|
{
|
||||||
|
gameObject = children[i];
|
||||||
|
|
||||||
|
this.scene.sys.displayList.remove(gameObject);
|
||||||
|
|
||||||
|
if (gameObject.preUpdate)
|
||||||
|
{
|
||||||
|
this.scene.sys.updateList.remove(gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.children.clear();
|
this.children.clear();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Add table
Reference in a new issue