pixijs / particle-emitter

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

Randomize config values #83

Closed LecodeMV closed 3 years ago

LecodeMV commented 6 years ago

Using an array instead of a primitive value would randomize a property in the update loop. Calling emitter.init manually with random new values isn't working.

Usage example:

    let emitter = new PIXI.particles.Emitter(container, art, {
      color: {
        list: [
          {
            value: "ffffff",
            time: 0
          },
          {
            value: [
              "69D2E7",
              "A7DBD8",
              "E0E4CC",
              "F38630",
              "FA6900",
              "FF4E50",
              "F9D423"
            ],
            time: 1
          }
        ],
        isStepped: false
      }
    });
andrewstart commented 6 years ago

PropertyNodes are shared between all particles of an emitter. Your example would involve all particles fading from white to a constantly changing shared color, would it not?

LecodeMV commented 6 years ago

Indeed...Would that be feasible to make each particle have its own randomized value ?

andrewstart commented 6 years ago

It should be feasible, but significantly more complicated. What I expect most people to want would be each particle being given a random (but stable for its lifetime) value/value list.

LecodeMV commented 6 years ago

Yes it's significantly more complicated, from what I've seen. I'll try again.

andrewstart commented 6 years ago

A potential method is to detect array values upon Emitter initialization, and create a PropertyNode chain for each possible combination. This is a brute force method though, I haven't yet thought of a cleverer solution.

andrewstart commented 3 years ago

With the behaviors introduced in release 5.0.0 it is easy to make a behavior to do whatever you need to.