Xenicle Posted April 6, 2014 Share Posted April 6, 2014 Is it possible to emite particles from one coordonate to another one with Phaser ? If it is, have you got exmple, a way to go ? Thanks ! Link to comment Share on other sites More sharing options...
localGhost Posted April 6, 2014 Share Posted April 6, 2014 Just to clarify a bit: and what trajectories they should have, in your vision? How that should look like? A conveyor? Link to comment Share on other sites More sharing options...
Xenicle Posted April 6, 2014 Author Share Posted April 6, 2014 I would like particles start from a spot where points have made and goes directly and rapidly to the score counter, perhaps like they where in an invisible tube. To ilustrate the score added.... Link to comment Share on other sites More sharing options...
localGhost Posted April 6, 2014 Share Posted April 6, 2014 Well, let me try to give you an idea. Have to warn it's coming initially from a 1.1.3 version game.Main point: the emitter is just a group. So, for example, with emitter em you can run:em.setAll('alpha', 0.5);em.forEach(myFunction, myParameter);So, for example, once particles are emitted, you should be able to set up a tween for moving every particle to the desired location. Not sure how to do it correctly with particles that are not emitted all in one shot though.Also I thought about something like MoveToPointer, but perhaps enabling even Arcade physics for emitted particles is a bad idea. Link to comment Share on other sites More sharing options...
Xenicle Posted April 6, 2014 Author Share Posted April 6, 2014 Thanks a lot for your idea, I Will try to do this and post my results. Link to comment Share on other sites More sharing options...
valueerror Posted April 7, 2014 Share Posted April 7, 2014 i'm doing this: (and i think you could adapt it to your needs) in create function: emitter = game.add.emitter(0, 0, 200); emitter.makeParticles('smoke',0,200,true,true); emitter.enableBody = true; emitter.physicsBodyType = Phaser.Physics.P2JS; emitter.setYSpeed(250, 0);(you don't need to enable body, physics type and speed.. this is just for my testcase where i want the smoke to move down when emitted.. and then (when needed):particleBurst(player);function particleBurst(player) { emitter.x = player.body.x; emitter.y = player.body.y; emitter.start(true, 2500, null, 10); //explode, lifespan, .. , count emitter.forEach(setUp, this);}this starts the emitter and calls setup for every particle:function setUp(particle){ if (!particle.exists) {particle.alpha=1;} game.add.tween(particle).to({ alpha: 0 }, 1000, Phaser.Easing.Cubic.Out, true); game.add.tween(particle.scale).to({ x: 2,y:2 }, 1000, Phaser.Easing.Cubic.Out, true);}this sets alpha for ever nonexistant particle to 1 (because i need to start every particle completely visible)and then it tweens the particles to alpha 0 and scales them to double their size (i'm creating wonderfull looking smoke with this ^^) Link to comment Share on other sites More sharing options...
Xenicle Posted April 7, 2014 Author Share Posted April 7, 2014 Thanks valueerror ! I've made my function like this :function emitteParticuleTo(x, y, xDest, yDest, nb, tm, particle){ var emitter = game.add.emitter(x, y, 100); emitter.makeParticles(particle); emitter.minParticleScale = 0.2; emitter.maxParticleScale = 0.4; emitter.start(true, tm, 20, nb); setTimeout(function(){ emitter.forEach(function(particle){ particle.gravity = 0 var tw = game.add.tween(particle).to({ x: xDest, y: yDest}, 500, Phaser.Easing.Linear.None, true, 0, false); tw.onComplete.addOnce(function(){ particle.kill(); }, this); }, this, false); }, 700); }And it work like I want it to work, anyway your example is realy interesting. Link to comment Share on other sites More sharing options...
Recommended Posts