Jump to content

Overlap sprite w/particle Phaser v2.6.2


GreatBigBore
 Share

Recommended Posts

I just fetched 2.6.2 and found that my game didn't work the same as before. After a lot of digging around, I found that the overlap handler was ignoring my particles because body.checkCollision.none is set to true. I overrode Phaser.Particle.prototype.onEmit() and set every particle's body.checkCollision.none to false, and my overlap works again. I'd love to fix it and submit a pull request, but last time I tried to do that, I discovered that phaser is a darned complex library with a lot of things to consider. Best leave it to those who know the lib better than I do.

And who knows, maybe this is not even a bug? Maybe I'm just setting up my emitter wrong?

Link to comment
Share on other sites

4th argument:

/**
* This function generates a new set of particles for use by this emitter.
* The particles are stored internally waiting to be emitted via Emitter.start.
*
* @method Phaser.Particles.Arcade.Emitter#makeParticles
* @param {array|string} keys - A string or an array of strings that the particle sprites will use as their texture. If an array one is picked at random.
* @param {array|number} [frames=0] - A frame number, or array of frames that the sprite will use. If an array one is picked at random.
* @param {number} [quantity] - The number of particles to generate. If not given it will use the value of Emitter.maxParticles. If the value is greater than Emitter.maxParticles it will use Emitter.maxParticles as the quantity.
* @param {boolean} [collide=false] - If you want the particles to be able to collide with other Arcade Physics bodies then set this to true.
* @param {boolean} [collideWorldBounds=false] - A particle can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.
* @return {Phaser.Particles.Arcade.Emitter} This Emitter instance.
*/
Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide, collideWorldBounds) {

 

Link to comment
Share on other sites

9 hours ago, rich said:

4th argument: Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide, collideWorldBounds) {

 

But that's for colliding. I'm talking about overlap. Maybe they're the same thing in this context? I didn't have to set that flag until I merged 2.6.2. Not that I'm complaining. Just wondered about your thoughts.

Link to comment
Share on other sites

As far as Arcade Physics is concerned an overlap is still a form of collision, it just doesn't have a response. Prior to 2.6.2 collides.none wasn't respected properly (for particles or anything else), but now is, so the flag is more important than before, because before, it was essentially broken, and made no difference what you set it to, and now it works.

You could definitely argue that an overlap check shouldn't care about the collision flags. But I really like being able to set them, and have an object excluded from the overlap sweep, which wouldn't be possible if it just ignored the flags completely.

Link to comment
Share on other sites

  • 2 months later...

Hi I have a similar problem. My game uses:

buildEmitter: function(){
	this.burst = this.add.emitter(0, 0, 80);
        this.burst.minParticleScale = 0.3;
        this.burst.maxParticleScale = 1.2;
        this.burst.minParticleSpeed.setTo(-30, 30);
        this.burst.maxParticleSpeed.setTo(30,-30);
        //this.burst.maxParticles = 80;
        this.burst.makeParticles('explosion',0,20,true,false);
        this.input.onDown.add(this.fireBurst, this);
},
	
fireBurst: function(pointer){ //passing input 
		this.burst.emitX = pointer.x; //do emitting in coords of the pointer (finger)
		this.burst.emitY = pointer.y;
		
		this.burst.start(true,2000,null,20); 
},

 

Earlier whit makerParticles('explosion'); constructor the game allowed to click 4 time each producing 20 particles. When added overlap(..) check I needed to modify emitter as follows: makerParticles('explosion',0,20,true,fale); constructor. Now I am only able to click 1 and produce 20 particles, other clicks are unresponsive until particles disappears.

I would like to know how to set a limit of 80 particles on the screen and be able to click 4 times (produce 20 particles each time) until the limit is reached = clicking doesnt do anything until some particles vanish, and still be able to check overlap collisions. 

Please help,

***

Ok I have found the solution. I have just started learning JS and Phaser so I did not know teher is 'undefined' variable type and using ('explosion',undefined,undefined,true,false); did the trick. Sorry for a useless post.

 

Edited by misfit
Found the solution
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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