Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
how to "clear all Particles" and know if they're gone? — Gideros Forum

how to "clear all Particles" and know if they're gone?

piepie Member
edited November 2016 in General questions
Hi, I am trying the new Particles object and I have some questions about it:
http://docs.giderosmobile.com/reference/gideros/Particles#Particles


I have a Particles object placed in a actor (Sprite), I add some particles with relatively short ttl when my actor is hit.
If actor hp drop below 1 he's sent to a pool.
my issue is double:
1) usually the actor dies while he's throwing particles, thus making a bad visual effect (actor and particles disappear all together)
2) sometimes the actor is respawned "instantly", and he is still throwing particles.

The most attractive option would be to wait for the particles to reach their end, and then remove my actor. But how do I know when the right time has come? (how do I know that my set of particles is empty? I know how many particles I "launched", but then? )

The Barbaric option would be to remove the Particle object from the actor when it dies, but then I would need to add a new one in its place on respawn, weighing heavy on resources. And it would still be "rough" because this won't fix issue#1.
A method to get rid of Particles would be cool anyway :)


I'd like to follow the first option, if anyone can suggest me how :)

I am trying to avoid Timer and delayedCalls this time, and up to now it seems worth it..

thank you

Comments

  • SinisterSoftSinisterSoft Maintainer
    edited November 2016
    You can now grab the collection of particles - you can also filter them by a special string value. if its the only thing that generates particles then no need for the filter, just check the size of the table that is returned - empty = no particles. If you have multiple things generating particles then add the filter as you create the particles to know which sprite 'owns' the particles.

    see: http://docs.giderosmobile.com/reference/gideros/Particles/getParticles#Particles:getParticles
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • That's great, thanks :)

    I assume that the filter you're speaking of is "tag", am I right?

    Another question: what's the difference between these?

    Particles:setParticleTag(i, tag)
    Particles:setParticlesTag()

    The usage of the first one is pretty clear, what about the other? I can assume it sets a tag for the whole particles set, but which tag is it setting? Is it missing a parameter from parenthesis in docs?

    Thank you
  • hgy29hgy29 Maintainer
    Ah, doc glitch, Particles::setParticlesTag() doesn't exist at all.

    Likes: SinisterSoft, pie

    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.