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:
Here’s the code:
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?