Skip to content

Commit 764de08

Browse files
committed
Camera.ignore can now take nested-arrays of Game Objects and also supports both Groups and Containers.
1 parent 84ef115 commit 764de08

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ The Tile Sprite Game Object has been given an internal overhaul to make it more
142142
* The `CanvasRenderer.DrawImage` function has been removed, as has the associated `drawImage` property from the Canvas Renderer as they're no longer used.
143143
* The `CanvasRenderer.BlitImage` function has been removed, as has the associated `blitImage` property from the Canvas Renderer as they're no longer used.
144144
* You can now access the Game instance directly from a Scene using `this.game` as long as it exists in the Scene's Injection Map, which it does by default. Be very careful what you do here: there's next to nothing you should actually use this for.
145+
* `Camera.ignore` can now take nested-arrays of Game Objects and also supports both Groups and Containers.
145146

146147
### Game Config Resolution Specific Bug Fixes
147148

src/cameras/2d/BaseCamera.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -825,24 +825,35 @@ var BaseCamera = new Class({
825825
* @method Phaser.Cameras.Scene2D.BaseCamera#ignore
826826
* @since 3.0.0
827827
*
828-
* @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObject - The Game Object, or array of Game Objects, to be ignored by this Camera.
828+
* @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group)} entries - The Game Object, or array of Game Objects, to be ignored by this Camera.
829829
*
830830
* @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance.
831831
*/
832-
ignore: function (gameObject)
832+
ignore: function (entries)
833833
{
834834
var id = this.id;
835835

836-
if (Array.isArray(gameObject))
836+
if (!Array.isArray(entries))
837837
{
838-
for (var i = 0; i < gameObject.length; i++)
839-
{
840-
gameObject[i].cameraFilter |= id;
841-
}
838+
entries = [ entries ];
842839
}
843-
else
840+
841+
for (var i = 0; i < entries.length; i++)
844842
{
845-
gameObject.cameraFilter |= id;
843+
var entry = entries[i];
844+
845+
if (Array.isArray(entry))
846+
{
847+
this.ignore(entry);
848+
}
849+
else if (entry.isParent)
850+
{
851+
this.ignore(entry.getChildren());
852+
}
853+
else
854+
{
855+
entry.cameraFilter |= id;
856+
}
846857
}
847858

848859
return this;

0 commit comments

Comments
 (0)