Jump to content

outOfBoundsKill does not work.. atleast for me


Uibon
 Share

Recommended Posts

Here is the code to the group creation in my game:

enemies1 = game.add.group();enemies1.enableBody = true;enemies1.physicsBodyType = Phaser.Physics.ARCADE;enemies1.createMultiple(5, 'e1');enemies1.setAll('outOfBoundsKill', true);

The problem is that the sprites are not being killed when they are out of world bounds so when I do this later in my update loop:

enemy = enemies1.getFirstExists(false);if(!enemy) {    console.log("No more Enemies.") }

The console repeatedly logs the message after the initial 5 are used up.

While 5 may seem like a small number of initial sprites they are sufficient as at any one time a total of no more than 3 sprites will be on the map.

 

Am I doing something wrong?

Link to comment
Share on other sites

You have to set the checkWorldBounds value to true.

 

From the migration guide:

  • By default Sprites no longer check if they are within the world bounds. It's quite an expensive process (calling getBounds every frame), so you have to enable directly.

 

For example:

enemies1.checkWorldBounds = true;
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...