Uibon Posted March 17, 2014 Share Posted March 17, 2014 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 More sharing options...
StrykerKKD Posted March 17, 2014 Share Posted March 17, 2014 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 More sharing options...
Learning By Doing Posted March 17, 2014 Share Posted March 17, 2014 try:enemies1.checkWorldBounds = true;enemies1.outOfBoundsKill = true; Link to comment Share on other sites More sharing options...
miguelgazela Posted March 18, 2014 Share Posted March 18, 2014 It should work with this code:enemies1 = game.add.group();enemies1.enableBody = true;enemies1.physicsBodyType = Phaser.Physics.ARCADE;enemies1.createMultiple(5, 'e1');enemies.setAll('checkWorldBounds', true);enemies1.setAll('outOfBoundsKill', true); quiphop 1 Link to comment Share on other sites More sharing options...
Recommended Posts