Simplest implementation of blinkingThe simplest way to get such an effect is to literally blink the sprite: Just don't draw it half the time.
var frequency = 200;
if (! blinking || Math.floor(Date.now() / frequency) % 2) {
ctx.drawImage(...);
}
So theThe idea is that if you setwhen blinking
is set to true
then it will based on time and frequency, blinking it on and off by just drawing or notthe sprite will flash at the given frequency
.