pixijs / particle-emitter

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

PathParticles cannot read property time of null #91

Closed ramako closed 5 years ago

ramako commented 5 years ago

Hello, I am trying to use the PathParticle but I keep getting that error. I have the extradata in the json with the path, when I removed that, I don't get the error.

This is the code I use to initialize it

            this._texture = PIXI.utils.TextureCache[ this._settings.texture ];
            this._emitter = new PIXI.particles.Emitter( this, this._texture, this._emitterSettings );
            this._emitter.particleConstructor = PIXI.particles.PathParticle;

This is the full error I am getting when I start the emitter: Uncaught TypeError: Cannot read property 'time' of null at t.r [as interpolate] (pixi-particles.min.js:8) at e.update (pixi-particles.min.js:8) at t.update (pixi-particles.min.js:8) at TickerListener.emit (TickerListener.js:99) at Ticker.update (Ticker.js:411) at Ticker._tick (Ticker.js:147) r @ pixi-particles.min.js:8

andrewstart commented 5 years ago

I assume that your particle has the same start & end speed? If so, I understand the bug and an immediate workaround for you would be to have slightly different start/end speeds, like 200 and 200.1

ramako commented 5 years ago

Hello, I am afraid that is not the case, the start and end speed is different, here is the json I am using { "alpha": { "start": 1, "end": 0.31 }, "scale": { "start": 0.42, "end": 0.82, "minimumScaleMultiplier": 1 }, "color": { "start": "#ff0505", "end": "#f76f00" }, "speed": { "start": 400, "end": 200, "minimumSpeedMultiplier": 1 }, "acceleration": { "x": 0, "y": 100 }, "maxSpeed": 400, "startRotation": { "min": 180, "max": 360 }, "noRotation": false, "rotationSpeed": { "min": 40, "max": 70 }, "lifetime": { "min": 0.25, "max": 2 }, "blendMode": "normal", "frequency": 0.012, "emitterLifetime": -1, "maxParticles": 10, "extraData": { "path": " (sin(x/50) * 20)" }, "pos": { "x": 0, "y": 20 }, "addAtBack": false, "spawnType": "rect", "spawnRect": { "x": -250, "y": 100, "w": 250, "h": 50 } } Removing the extra data property will make it work

andrewstart commented 5 years ago

Ah, the end speed is ignored/removed because you have acceleration.

andrewstart commented 5 years ago

PathParticles were never designed to use the acceleration property, because their position is locked to the path. In their update they overwrite the position of the particle, so any movement due to acceleration would be ignored.

ramako commented 5 years ago

Hello, yes, that seems to have solved the problem, it was the acceleration property, needs to be locked to 0. Thank you.