Check that animation frames really sit where the sprite sheet says they do
A character that flickers, shows half of the next frame or points to an empty square is often a sheet whose border and gaps were counted wrong. This entry shows how to get the frame positions right and catch frame numbers that do not exist.
Why this works
Pictures know nothing about the grid in your head, so the drawing code needs exact positions. Working them out from the sheet's real borders and gaps, and refusing numbers that point past the last frame, leaves no room for a guess that shows up as flicker.
When not to use it
Skip it when frames differ in size or are packed tightly by a tool that writes its own list of positions. Then use that list as given, because a regular grid does not describe the sheet. Check the list itself instead.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 33 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Check that animation frames really sit where the sprite sheet says they do" (read_entry sprite-sheet-frames-and-spacing) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP