dabar Posted March 11, 2017 Share Posted March 11, 2017 Hello, I have just purchased the Particle Storm plugin. I like it a lot and it makes it easy to make complicated things, but I cannot make a simple thing easily. What I would like to do is stop/remove/hide the particle effect/emitter when the user is starting a new round and then show it again when needed. That's where I am stuck - I simply can't manage to do something as simple as hiding/stopping/removing the particles. I searched through the docs but I can't seem to find an opposite of the .emit() method, i.e. a way to stop it? Then as a last resort I tried to destroy the emitter object and then recreate it when needed, but even that doesn't work. I though my code was causing the problem somewhere but then I took one of the examples (pixel_renderer_01.html) and just added a call to destroy after 2sec at the end of the create method and it generates the same error in the console as my code: Uncaught TypeError: Cannot read property 'add' of null at Phaser.ParticleStorm.Particle.create (particle-storm.min.js:2) at Phaser.ParticleStorm.Particle.reset (particle-storm.min.js:2) at Phaser.ParticleStorm.Emitter.emitParticle (particle-storm.min.js:2) at Phaser.ParticleStorm.Zones.Line.emit (particle-storm.min.js:2) at Phaser.ParticleStorm.Emitter.emit (particle-storm.min.js:2) at c.Timer.update (phaser.min.js:19) at c.Time.updateTimers (phaser.min.js:19) at c.Time.update (phaser.min.js:19) at c.Game.update (phaser.min.js:12) at c.RequestAnimationFrame.updateRAF (phaser.min.js:18) at window.requestAnimationFrame.forceSetTimeOut._onLoop (phaser.min.js:18) Attached you can find the example file with the code added by me, I believe I really didn't manage to do anything wrong in those 5 lines (my code is lines 64 to 73)? Or am I taking a completely wrong approach, what should I do to stop the emitter when needed and then restart it again when needed? Kind regards, Darko pixel renderer01.html Link to comment Share on other sites More sharing options...
samme Posted March 11, 2017 Share Posted March 11, 2017 I don't know ParticleStorm, but with the standard emitter you do emitter.on = false to stop a running particle flow or emitter.exists = false to hide any active particles. (Try the controls in phaser-debug-emitter) In Phaser destroy is permanent, you can't reuse an object after that. Link to comment Share on other sites More sharing options...
dabar Posted March 11, 2017 Author Share Posted March 11, 2017 Thanks for your suggestions. I found the "on" property earlier and tried it, but with no luck. Now I have tried the "exists" and "visible" properties, but the emitter doesn't respond to them - no changes. I have also tried calling methods "kill" and "removeAll" from the link provided but again, they do not help - they are not defined. I am aware destroying is permanent, but I tried that as a last resort as I couldn't achieve what I wanted in any other way, I'd have re-instantiated it again when needed, but I didn't manage to destroy it either as some "add" is called and causes an error. Link to comment Share on other sites More sharing options...
samme Posted March 11, 2017 Share Posted March 11, 2017 Seems there is emitter.enabled = false emitter.paused = true Link to comment Share on other sites More sharing options...
dabar Posted March 11, 2017 Author Share Posted March 11, 2017 Tried those before but they do not suit my needs, they do stop emitting of new particles, but the old ones still remain on the screen and I don't know how to hide/remove them? I have an infinite particle effect running, that's why I need to hide it manually when needed as it won't disappear by itself. Link to comment Share on other sites More sharing options...
samme Posted March 11, 2017 Share Posted March 11, 2017 For the Sprite renderer, it looks like you can do emitter.renderer.display.visible = false Mike 1 Link to comment Share on other sites More sharing options...
dabar Posted March 11, 2017 Author Share Posted March 11, 2017 Bravo, it works! Thanks a lot! It didn't occur to me to look up into renderer, although I started with Phaser just 2 days ago so I hope I'm excused However, I assume there is still an issue with the destroy method not working as it should? Or maybe it works but I was calling it wrong? Maybe a material for the authors to look into? Link to comment Share on other sites More sharing options...
Recommended Posts