Our current usage of setInterval
is great for spawning enemies and power-ups, but there are some drawbacks that we need to address. Since setInterval
functions still call themselves when switching to another tab, we need a way to clear these intervals, then restart them when navigating away from our game. We'll learn how to do exactly that, right here.