Draw sprite as all white or black

Hello! I'm using Mac SDK 2.5.0.

When an enemy is taking damage, I'd like to flash its sprite to all white and/or black while retaining its clear (transparent) background color.

I realize I could do this via an imagetable and literally create these two extra all white/black images and switch between them, but shouldn't I be able to use setImageDrawMode() to do this? I imagine this would be more performant, it certainly would be more convenient.

That said, after I've declared, asserted, and defined the sprite with its image object, I'm unclear how or if I'm able to redraw it in a different mode. My attempts to simply declare gfx.setImageDrawMode(gfx.kDrawModeFillWhite) in the sprite's :update loop do nothing, as does calling self:markDirty() either before or after that statement.

Even calling gfx.setImageDrawMode(gfx.kDrawModeFillWhite) before the declaration, assertion, and sprite definition of the image object has no effect.

I'm unclear from the documentation how to properly use this feature, nor can I find any examples or threads explaining it. Any help would be greatly appreciated, I'm stumped and just considering the manual imagetable route.

There’s two different setImageDrawMode functions. playdate.graphics.setImageDrawMode which sets the mode for whatever images get drawn directly by you and playdate.graphics.sprite:setImageDrawMode which sets the mode for the sprite’s image.

The call you want inside your sprite method likely looks like this: self:setImageDrawMode(gfx.kDrawModeFillWhite)

Aha, confirmed! Yes, I understand now -- Thanks so much for pointing out that distinction.