Workshop › Candy Crush-style Match 3 › Step 17 of 29
While clearing, the matched gems flash white: every few frames they switch between white and their color. And clicks are only taken while the game is idle.
```js
const flashing = phase === 'clearing' && matched.has(r * N + c) && Math.floor(timer / 3) % 2 === 0
ctx.fillStyle = flashing ? '#ffffff' : COLORS[gem]
if (phase !== 'idle') return
```matched.has), and Math.floor(timer / 3) % 2 is
0, which switches on and off every 3 frames.draw, replace ctx.fillStyle = COLORS[gem] with the two lines.if (phase !== 'idle') return the first line of the click listener.Skills: Drawing on a canvas, Game states
← Wait before clearing Cascades →