A 2D character walking across the screen is not one picture sliding sideways. It is a handful of separate drawings — foot forward, foot down, foot back — shown in quick succession until your eye reads them as motion. All of those drawings usually live in a single image file, arranged in a neat grid. That file is a sprite sheet.

Four things have to line up for that grid to become an animated character: the sheet (where the pictures are stored), the cell (which pixels belong to one drawing), the clip (which drawings play in what order), and the timing (when to switch from one drawing to the next). Most sprite-sheet confusion comes from mixing these up, so here is the whole chain first, then each link.

PieceThe question it answers
Sprite sheetWhere do all the pictures live?
Cell / source rectangleWhich pixels of the image are frame 8?
ClipWhich frames make up "walk", and in what order?
TimingHow long does each frame stay on screen?

One warning about the word "frame"

In the game-loop article, a frame was one pass through the loop: read input, update, draw. Here a frame means one still drawing of a character. These are unrelated clocks, and the gap between them is where animation bugs come from — a game running at 144 FPS does not play your walk cycle 144 times a second.

What a sprite sheet actually is

A sprite is a small rectangular image drawn at a position in the world. A sprite sheet is one image file — an ordinary PNG, nothing special about the format — that contains many sprites, usually in a regular grid.

Say the sheet is 192×128 pixels and each cell is 32×32. That gives 6 columns and 4 rows: 24 cells in one file, enough for a walk cycle, an idle, a jump, and some leftovers. Nothing inside the PNG records that layout. The file is only pixels; the knowledge that cells are 32 wide and there are 6 per row lives in your project settings or in code. (Some art pipelines ship a separate data file, often JSON, listing each sprite's rectangle by name — that is the exception, not the rule.)

The image is never actually cut

This is the mechanism people miss. When a game draws "frame 8" of a sprite sheet, it does not slice the file, save 24 images, or copy pixels around. The sheet sits in memory as one texture, and the draw call is told two things: which rectangle of that texture to read, and where to put it.

Engines expose this at different levels, but it is the same operation underneath. MonoGame asks you to pass a source rectangle to every sprite draw 3. Unity's Sprite Editor "slice" step records a rectangle for each sprite in the texture, then draws those rectangles as individual sprites 2. Godot does it through a frame index: put the sheet in a Sprite2D, set the horizontal and vertical frame counts, and frame selects a cell 1.

Once you know the cell size and the number of columns, the rectangle for any frame index is pure arithmetic. With cells w×hw \times h and CC columns:

col=i mod Crow=⌊iC⌋x=col⋅wy=row⋅h\text{col} = i \bmod C \qquad \text{row} = \left\lfloor \frac{i}{C} \right\rfloor \qquad x = \text{col}\cdot w \qquad y = \text{row}\cdot h

For the 192×128 sheet with 32×32 cells and 6 columns, frame 8 gives col=8 mod 6=2\text{col} = 8 \bmod 6 = 2, row=⌊8/6⌋=1\text{row} = \lfloor 8/6 \rfloor = 1, so the rectangle starts at x=64x = 64, y=32y = 32 and covers pixels 64–95 across and 32–63 down. Frame 7 is the last one in the first row; frame 8 begins a new row at the same left edge.

One caveat on that formula: it counts rows from the top of the image. Most 2D engines number cells left to right, top to bottom, but rectangle coordinates themselves may be measured from the bottom-left corner (Unity's sprite Y values are), so check which origin your API uses before writing the math by hand. Sheets also sometimes have padding between cells, which the engine's slicing settings exist to describe 2.

A clip gives the cells meaning

Cells by themselves are just pictures. A clip — Godot calls it an animation inside a SpriteFrames resource — is a named list of cells plus playback rules: walk = frames 0–5, jump = 6–9, idle = 12–13, and whether the clip loops or holds its last frame 4.

That list is what your game logic switches between. When the player presses right, you tell the sprite "play walk"; when they stop, "play idle". Which cells form which clip is your choice when slicing — the grid gives you 24 cells, but nothing in the image says the first six are a walk cycle.

The timing: animation speed is not game speed

Here is the bug almost everyone writes first. You draw the current cell, then advance the index once per game frame:

1cell_index += 1

That is the pixel-per-frame mistake from the game-loop article wearing different clothes. At 60 FPS, a 6-frame walk cycle finishes in a tenth of a second and repeats — a frantic blur. At 30 FPS the same code plays it at half the speed. Animation speed is tied to hardware again.

The fix is the same idea: measure time in seconds, not loop iterations.

1cell_index = 0
2cell_timer = 0.0
3anim_fps  = 10                 # sprite frames per second
4clip      = [0, 1, 2, 3, 4, 5] # cells of the sheet, in order
5
6def update(delta):
7    cell_timer += delta
8    step = 1.0 / anim_fps
9    while cell_timer >= step:
10        cell_timer -= step
11        cell_index = (cell_index + 1) % len(clip)
12    draw(sheet, cell_rect(clip[cell_index]))

Three details matter. anim_fps belongs to the artwork, not the display: 10 sprite frames per second means each drawing stays up for 0.1 seconds no matter how fast the loop runs — on a 60 FPS game, that is six loop frames per drawing. The % len(clip) wraps the index back to the start, which is what makes the clip loop. And the timer subtracts one step instead of resetting to zero, so leftover time carries into the next go; without that, a clip would drift slightly faster or slower than intended.

The while rather than if covers the rarer case where one long frame — a level load, a hitch — spans two or more sprite frames, so the animation catches up instead of falling behind.

Making one, converting one, cutting one back up

To make a sprite sheet, draw each pose inside the same grid — a 32×32 grid means every pose is drawn in a 32×32 square with the character consistently placed — then export the whole grid as one PNG. Aseprite or Photoshop can show the grid; free web tools will pack frames for you.

Frames also arrive from other places. If you have an animated GIF, a gif to sprite sheet converter lays its frames into rows a game engine can read. If you only have a sheet and need individual files, a sprite sheet cutter splits the grid back into separate images. And if the engine can slice on import — Unity's Sprite Editor offers grid-by-cell-size and grid-by-cell-count slicing with offset, padding and pivot settings 2 — you can skip splitting entirely and keep one file.

Why pack them into one file at all?

Convenience is only half the reason. Every time a renderer draws with a different texture than the previous draw, it pays a cost to swap textures; enough swaps per frame and the CPU becomes the bottleneck 3. Sprites sharing one texture can be submitted together in a single batch. So the same file does two jobs: it stores an animation's frames, and it doubles as a texture atlas — one image holding many graphics so they can be drawn efficiently. The two names describe nearly the same object with different intent: "sprite sheet" is what animators say about a character's frames, "atlas" is what renderers say about any packed image.

What usually goes wrong

  • The grid does not divide evenly. 192 pixels wide with 32-pixel cells is exactly 6 columns. Off by one pixel and each frame drifts slightly relative to the last, so the character seems to wobble as the clip loops.
  • Frames were trimmed to their visible content. Some exporters crop away transparent margins per frame; the drawings are then different sizes and the character jumps between positions. Keep a fixed cell size with transparent padding inside it.
  • The pivot is inconsistent. Placement and rotation reference a pivot point; if one frame's pivot is at the feet and another's at the centre, the sprite shudders when it turns.
  • The row order is assumed. Index-to-rectangle math assumes a specific scan order. A sheet exported column by column will look scrambled under the formula above.
  • Animation FPS was confused with game FPS. The most common cause of "my animation is too fast".

What to hand an AI coding tool

The sheet is data, so an AI tool cannot guess your layout. Give it the numbers: the image file, the cell size in pixels, the number of columns, which cells form each clip, each clip's playback speed, and whether it loops. Something like: "hero.png, 32×32 cells, 6 columns. walk = cells 0–5 at 10 FPS looping, idle = cells 12–13 at 6 FPS looping. Advance with delta time." That sentence plus the file is enough for correct drawing code, and it removes the guesswork that produces jitter, drifting grids and animations that run at monitor speed.

From there, the cell is just a rectangle, the clip is just a list, and the timing is just delta time again — three small pieces that turn a static image into a character that walks.