pixijs / particle-emitter

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

Correct Way to Make Pixi-Particles Interactive #125

Closed KamiFightingSpirit closed 4 years ago

KamiFightingSpirit commented 4 years ago

I am trying to edit my emitter based off of different events (mouseover, mouseout etc)

Is there a guide to how to do this? I am finding that some things can only be edited once (minimumScaleMultiplied for example) and others just don't work (editing minR on the "ring" type emitter).

My approach currently was to just do direct edits to the emitter object:

    enterText.mouseover = function(mousedata) {

        //edit the emitter
        emitter.minimumScaleMultiplier = 5;
        // emitter.spawnCircle.minR = 15;
        // emitter.minLifetime = 4;
        // emitter.maxLifetime = 4;
        // console.log(emitter.minLifetime, emitter.maxLifetime);
    };

Any help?

andrewstart commented 4 years ago

As you closed this, I assume that you figured out that pretty much anything can be edited on the emitter, but it won't affect existing particles. For that you would have to modify each particle by reference.

KamiFightingSpirit commented 4 years ago

Thanks Andrew, yes, I figured out how to edit the emitter object. However, with what you said, how do you select existing particles? Trying to locate the array...

andrewstart commented 4 years ago

Your mistake is looking for an array! Due to all of the pushing, shifting, and slicing that would occur, particle references are stored as doubly linked lists. The list of live particles can be accessed from the protected property _activeParticlesFirst.

KamiFightingSpirit commented 4 years ago

If you don't mind me asking, why are there some variables that are setup in different ways? For instance, on a particle, scale. It is setup both by itself as well as within transform.scale

andrewstart commented 4 years ago

DisplayObject.scale is a convenience getter for DisplayObject.transform.scale. Any scale related properties on Particle itself are for calculating scale at any given time, rather than the current state.