Sprite flicker for iframes

Using Mac SDK 2.5.0

I could use some help getting my head around this sprite manipulation: When the player gets hit, they're granted 2 seconds of invulnerability. To visually represent this, I'd like the player's sprite to flash between transparent and its normal state.

I've managed to make the player completely transparent by using :clear(gfx.kColorClear) -- But how would I return the sprite to its "default" state with all of the original image contents? Do I need to reload the image, or is there an overall better way to go about this?

Thanks for your help!

Hello, you could probably use playdate.graphics.sprite:setVisible(flag)


Thanks, Jakub! That works perfectly.

1 Like