Jump to content

how to release resource of one time particle system


davychen
 Share

Recommended Posts

Thanks, and hello again, DC!  The important question is... did YOU get the info you needed?  I hope so.

It would be handy if our particle systems were able to generate an "allParticlesDead" event or callback.  Unfortunately, it does not look possible/wise.

So, I guess, the delayed-start particles.length-checker...  is a viable option.

http://playground.babylonjs.com/#206JUO#5

(Lines 68-75).  I put the timer on the particle system itself.  I tried to change all 'ps1' to 'this' in that function, but I failed.  I was trying to get a particleSystem for you... that was self-contained.  Your game... because of its rapid-fire feature (which I love)... needs to allow many particle explosions happening at the same time.  This is why re-using the same particle system without disposing... won't work for you.  You already know that.  :)

 

The time-based particle explosion WOULD work, maybe.

http://playground.babylonjs.com/#206JUO#7

Not a bad momentary explosion, thanks to line 46 - ps1.targetStopDuration = .25;  The particles seem to have proper time to die of old age... before the particleSystem is disposed.  It looks pretty good...  no extra timer needed.  I like it.

I turned OFF manualEmitCount and set an emitRate in lines 43-44.  I still have disposeOnStop in line 67. 

You can ignore/remove lines 72-74.  They are only for checking if scene.particleSystems finished empty after the previous RUN.  It properly ends empty, yay!

Maybe, using targetStopDuration will work better than manualEmitCount for your game.  *shrug*  It is worth testing, I think. 

Fun experiments!  Good luck... keep us updated on your games and experiments, DC! 

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...