spawnSparkleBurst method

void spawnSparkleBurst(
  1. Vector2 at, {
  2. int count = 8,
})

Acquires count SparkleParticles from sparklePool, fans them out radially from at, and adds them to the component tree. Each one returns itself to the pool automatically (via PooledComponent) once its own lifetime ends and Flame removes it — no manual release bookkeeping needed at the call site.

Implementation

void spawnSparkleBurst(Vector2 at, {int count = 8}) {
  for (var i = 0; i < count; i++) {
    final particle = sparklePool.acquire();
    final angle = (i / count) * 2 * math.pi;
    particle
      ..reset(
        position: at,
        direction: Vector2(math.cos(angle), math.sin(angle)),
        color: NeonTheme.gemColors[i % NeonTheme.gemColors.length],
      )
      ..attachToPool(() => sparklePool.release(particle));
    (showClassicDemo ? this : world).add(particle);
  }
}