mk12001 Posted August 27, 2015 Share Posted August 27, 2015 Hi, I'd like to understand the group outOfBoundsKill function. so I created a group, soldiers, in my create method: soldiers = game.add.group();soldiers.enableBody = true;soldiers.physicsBodyType = Phaser.Physics.ARCADE;soldiers.setAll('outOfBoundsKill',true);soldiers.setAll('checkWorldBounds',true);createSoldiers(); And I created a separate function, createSoldiers() to create individual objects under that group. function createsoldiers(){for (var ctr = 0; ctr < 4; ctr++) { var soldier = soldiers.create(game.world.randomX, 100, 'soldierSprite'); soldier.anchor.setTo(0.5, 0.5); soldier.body.moves = false; }}For some reason, even if the soldiers are already out of bounds, the soldiers.setAll('outOfBoundsKill',true); doesn't kill it as checked from console.log("candies" + candies.countLiving()); I did something like the code below but I couldn't make the code to work due to an error that soldier isn't existing (not sure how to pass the object as an argument if it's in a group).function checkCandies(){for (var ctr = 0; ctr < 4; ctr++){soldier.events.onOutOfBounds.add(destroySoldier, this);}}function destroyCandy(soldier){soldier.kill();}In the invaders sample (http://phaser.io/examples/v2/games/invaders), there's a resetBullet function that isn't called. Not sure if it's automatically called by the system. Link to comment Share on other sites More sharing options...
mk12001 Posted August 28, 2015 Author Share Posted August 28, 2015 up Link to comment Share on other sites More sharing options...
Staafsak Posted August 29, 2015 Share Posted August 29, 2015 Hello,Are you using the latest version of Phaser? Link to comment Share on other sites More sharing options...
Recommended Posts