totallybueno Posted September 2, 2014 Share Posted September 2, 2014 Hi there,so here´s my question... I have a game, you´re under the water and at some point you launch some particles (bubbles). What I want is to deleted those particles when they arrive to de surface but I don´t know how to do that, I don´t know if I should extend de particle class or if there´s another method. Note: I can´t use checkWorldBounds because not all the stage (world) is water. Link to comment Share on other sites More sharing options...
valueerror Posted September 2, 2014 Share Posted September 2, 2014 is the water surface always on the same y position ? if so you could just check the current y position of the particles (if thats possible) and remove them .. or you create a sensor rectangle that resides on top of the water and on collision with this rectangle you remove the particles? Link to comment Share on other sites More sharing options...
lewster32 Posted September 2, 2014 Share Posted September 2, 2014 Something like this will do the trick:function update() { emitter.forEachAlive(function(bubble) { if (bubble.y < surfaceY) { bubble.kill(); } });} valueerror 1 Link to comment Share on other sites More sharing options...
totallybueno Posted September 2, 2014 Author Share Posted September 2, 2014 Thanks for the answer valueerror, but I just fixed it this way:this.game.world.bounds = new Phaser.Rectangle(0,100, this.game.world.width, this.game.world.height);andemitter.forEach(function(particle){ particle.checkWorldBounds = true; particle.outOfBoundsKill = true;}, this); Link to comment Share on other sites More sharing options...
totallybueno Posted September 2, 2014 Author Share Posted September 2, 2014 Thanks lewster32, that´s closer to what I did Link to comment Share on other sites More sharing options...
lewster32 Posted September 2, 2014 Share Posted September 2, 2014 Not sure if you should be manually changing the world bounds like that - it may have other repercussions, as it should normally not be smaller than the screen. Also, checking world bounds is quite a bit less efficient as bounds checks have to be done each time. As the particles are small and evenly sized, just checking their y property should be enough to get what you want. totallybueno 1 Link to comment Share on other sites More sharing options...
totallybueno Posted September 2, 2014 Author Share Posted September 2, 2014 Ops, that´s true... I´m gonna change it this way. Thanks again Link to comment Share on other sites More sharing options...
Recommended Posts