# effects.clearParticles() doesn't clear particles?

**URL:** <https://forum.makecode.com/t/effects-clearparticles-doesnt-clear-particles/14373>\
**Category:** Help\
**Created:** [July 7, 2022, 11:41pm UTC](https://forum.makecode.com/t/effects-clearparticles-doesnt-clear-particles/14373 "2022-07-07T23:41:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [July 7, 2022, 11:41pm UTC](https://forum.makecode.com/t/effects-clearparticles-doesnt-clear-particles/14373/1 "2022-07-07T23:41:11Z")

</div>

I started a simple project for a two-player TRON-style light cycle game, and ran into an oddity where I can’t figure out how to stop a sprite effect.

It’s supposed to trigger an explosion when there’s a crash, and then clear the particles when starting the next round. However, the particles still stick around which looks odd:

> **[light cycle racer](https://arcade.makecode.com/42872-93704-54937-42605)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Here’s the code:

```auto
        s1.startEffect(effects.fire, 500)
        pause(1000)
        reset()

function reset() {
    [...]
    bg.fillRect(0, 0, 160, 120, 0)
    bg.drawRect(0, 0, 160, 120, 1)
    effects.clearParticles(s1)
    effects.clearParticles(s2)
    if (game.currentScene().particleSources) {
        game.currentScene().particleSources.forEach(ps => ps.destroy())
    }
}

```

The particleSources loop was a brute-force attempt to get rid of leftover particles. Apparently the particles are distinct from particle sources - is there a clean way to get rid of them?

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [July 8, 2022, 5:44pm UTC](https://forum.makecode.com/t/effects-clearparticles-doesnt-clear-particles/14373/2 "2022-07-08T17:44:34Z")

</div>

I’d have to look at the source to remember the exact justification behind it because we haven’t touched the particle effects in a while, but the `effects.clearParticles` clears the sources but lets the particles live out the rest of their lifespan so that it ‘looks nice’. `particles.clearAll()` does a full clear of all the particles on the screen for you

---

<div class="post-metadata">

**Author:** ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)\
**Post date:** [July 8, 2022, 6:18pm UTC](https://forum.makecode.com/t/effects-clearparticles-doesnt-clear-particles/14373/3 "2022-07-08T18:18:12Z")

</div>

Thanks, `particles.clearAll()` works great for this purpose.

Do you think this would be helpful to add a note in the documentation at [https://arcade.makecode.com/reference/effects/clear-particles](https://arcade.makecode.com/reference/effects/clear-particles) ? Though I don’t know if there’s a way to call it from Blocks.

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [July 8, 2022, 6:25pm UTC](https://forum.makecode.com/t/effects-clearparticles-doesnt-clear-particles/14373/4 "2022-07-08T18:25:07Z")

</div>

Hm probably yes, good point. Here’s that: [https://github.com/microsoft/pxt-common-packages/pull/1358](https://github.com/microsoft/pxt-common-packages/pull/1358)
