Here's a quick example of how you can pool instances of a sound effect in Tetra! There's a few advantages to doing this:
- You cap the number of identical sounds that can play at once, which avoids you accidentally calling
playin a loop and blowing out your speakers (not speaking from experience, honest
- It gives you a central place to apply variations to the sound - e.g. you could make it so the pitch gets set to a slightly randomized value each time.
- It's probably slightly more performant than spawning new
SoundInstances every time (as always, avoid premature optimization).