Skip to content

Commit 8e880ed

Browse files
committed
Merge pull request phaserjs#2402 from jakewilson/dev
Added ability to kill a Game Object when it leaves camera bounds.
2 parents 4298b2c + ae663f9 commit 8e880ed

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/gameobjects/components/InWorld.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ Phaser.Component.InWorld.preUpdate = function () {
4040
else
4141
{
4242
this.renderable = false;
43+
44+
if (this.outOfCameraBoundsKill)
45+
{
46+
this.kill();
47+
return false;
48+
}
4349
}
4450
}
4551

@@ -99,6 +105,15 @@ Phaser.Component.InWorld.prototype = {
99105
*/
100106
outOfBoundsKill: false,
101107

108+
/**
109+
* If this and the `autoCull` property are both set to `true`, then the `kill` method
110+
* is called as soon as the Game Object leaves the camera bounds.
111+
*
112+
* @property {boolean} outOfCameraBoundsKill
113+
* @default
114+
*/
115+
outOfCameraBoundsKill: false,
116+
102117
/**
103118
* @property {boolean} _outOfBoundsFired - Internal state var.
104119
* @private

0 commit comments

Comments
 (0)