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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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