scheffgames Posted February 14, 2017 Share Posted February 14, 2017 I'm creating an emitter with 1 particle (for the sake of example) and I'm starting the emitter using flow. var emitter = game.add.emitter(game.world.centerX, game.world.centerY, 1); emitter.makeParticles("square"); emitter.width = game.world.width; emitter.height = game.world.height; emitter.setRotation(0, 0); emitter.gravity = 0; emitter.setYSpeed(-10, 10); emitter.setXSpeed(-10, -40); emitter.flow(0, 10, 10, -1, true); Now I'd like to be able to change the particle velocity (the xSpeed and ySpeed of emitter as regarding that specific particle) at one point in the game (for example when the particle reaches the world bounds I want it to gently flow back towards a random point on the screen). I've tried setting the emitter.setYSpeed and emitter.setXSpeed after I've started it but it doesn't work. Next I'v looked at the particle properties and methods and couldn't find a velocity or force property - sure enough there's a checkWorldBounds property that will launch an event when the particle reaches the world bounds but what am I supposed to do with it if I want to change the particle movement direction? Then I tried tinkering with forEachAlive function - takes a callback that enumerates over every particle. I've tried various things in the callback function (like setting a tween, modifying x and y directly, randomly create tweens after certain periods of time) but the overall movement looks jaggy/forced/unnatural. So anyone have any ideas or should I just roll my own emitter? Thanks! Link to comment Share on other sites More sharing options...
scheffgames Posted February 14, 2017 Author Share Posted February 14, 2017 Solved it in a matter of speaking. I'm using setXSpeed and setXSpeed set to zero value and I've rolled my own tweening code that changes the direction of particle and moves it randomly while trying to keep within world bounds. If anyone needs the code let me know. Link to comment Share on other sites More sharing options...
Recommended Posts