Day 23 of my little platformer. The character can run and jump, and today I wanted enemies to react when they get hit. Many games do this with a quick flash: for one or two frames, the sprite turns into a bright, flat version of itself. I tried a cheap way to get there by taking the existing run frames and using a tool to invert image copies of them, then looking at what I could reuse.
The plan
I have twelve frames of the enemy's walk cycle, each a small PNG with a transparent background. The idea:
- Flip the frames so dark outlines become light.
- Check whether the result reads as a "hit" effect.
- Pick the best frame or two for the game.
I did not expect a perfect result. I wanted a prototype I could look at in motion within the hour.
Flipping the frames
I opened a browser tool for flipping colors and dropped a frame in. It says local files stay on the device, and there is no account or watermark, which is a nice bonus when your assets are unreleased. PNG and WebP keep transparency, and JPEG puts transparent areas on white, so I exported PNG. The output keeps the original pixel dimensions, which matters a lot for pixel art. A frame that changes size by one pixel will wobble in the animation.
Inversion subtracts each channel from 255. My enemy is a dark purple creature with a grey outline. After flipping, it became a pale yellowish creature with a nearly white outline. It looked odd at first glance and surprisingly good at 60 frames per second.
Why a flip works as a flash, and where it does not
For a one-frame flash, the key is contrast against the normal frames. A flipped sprite is the complement of what the player has been seeing, so it catches the eye. That is a good thing here.
It does not give you a clean, flat-white silhouette, though. Mid-tones stay as mid-tones, only reversed. For a true white flash, I will need to do something else, such as filling every opaque pixel with white in the engine. For now, the flipped frame is a decent placeholder.
The strength slider
The tool has a strength slider, so I tried values below 100%. At about 60%, the sprite looked washed out, a little like it was fading. That turned out to be better for a "stunned" state than for a hit. I saved that frame under a different name for later.
Batch for the whole sheet
I did not want to do twelve frames by hand. The site has a batch page that takes up to 30 images at 20 MB each, applies the same settings to all of them and exports a ZIP. I put my twelve frames in, took the ZIP, and unpacked it into a flash/ folder next to the originals. The batch color inverter page was faster than I expected.
Putting it in the engine
In the game, the hit logic is simple: when a hit lands, swap the current frame for its flash/ twin for two frames, then swap back. I keep the same filenames in both folders, so the lookup is a one-line change.
func show_hit_frame(frame_index: int) -> void: sprite.texture = flash_frames[frame_index] await get_tree().create_timer(0.05).timeout sprite.texture = walk_frames[frame_index] What I learned
- Keep the exact pixel size when processing sprites.
- Use PNG for transparent sprites.
- A flipped sprite is a quick placeholder for flash effects, not a final one.
- Batch processing saves a surprising amount of time.
Tomorrow I will try tinting the flash in the engine and compare it with today's version. Until then, the enemies flicker when hit, and it already feels more satisfying than before.