pixijs / particle-emitter

A particle system for PixiJS
http://pixijs.io/particle-emitter/docs
MIT License
786 stars 124 forks source link

Question: Spawning a "burst" of particles. #124

Closed samcreate closed 2 years ago

samcreate commented 4 years ago
  1. I'm trying to create the "fizz" effect inside a soda bottle
  2. It's going to be parallaxed (similar to this affect https://matthew.wagerfield.com/parallax/)
  3. I'd like to generate a burst of particles based on the mouse speed. (imagine that your mouse has created more 'soda fizz" by it's movement)

I have the particles emitting at a good rate, and a function that calculates speed, but I can't figure out for the life of me this best approach to generate more bubbles on demand?

andrewstart commented 4 years ago

The emit property starts and stops emission of particles. If you aren't sure how to plug in your speed function, emission rate is controlled by the frequency property (must be greater than 0). You might find it cleanest to subclass Emitter and override the frequency getter and setter, which could also make it easier to play around with the parent getter to put your particles in different containers for parallaxing (it will probably be a lot more complicated than just that).

andrewstart commented 2 years ago

Release 5.0.0 adds Emitter.emitNow() , which will let you emit particles on demand, although it may not work as seamlessly as the normal update loop if you are moving the emitter to follow the mouse.