Godot 4 · sprite sheets · 29 Nov 2026
How to make a Godot 4 SpriteFrames (.tres) from a sprite sheet
Short answer: in Godot 4, add an AnimatedSprite2D, give it a New SpriteFrames, open the SpriteFrames panel and use Add frames from a Sprite Sheet: set Horizontal to the number of frames per row and Vertical to the number of rows, select one row, then set its FPS and loop. If your sheet has many animations or many colour variants, a 40-line Python script (below, MIT) can write the .tres file for every row at once, because a SpriteFrames resource is plain text.
Before you start: two settings that save an hour
- Nearest filtering for pixel art: Project Settings › Rendering › Textures › Canvas Textures › Default Texture Filter =
Nearest. Otherwise 16x16 sprites look blurry. - One row per animation, fixed cell size. Both methods below assume a grid: every frame is the same width and height, and each row holds one animation (idle, walk, hurt…). Empty cells at the end of a short row are fine.
Method 1 — the editor dialog (best for one or two animations)
- Add an
AnimatedSprite2Dnode. In the Inspector, click Sprite Frames › New SpriteFrames, then click the new resource: the SpriteFrames panel opens at the bottom. - Rename the
defaultanimation (double-click it), e.g.idle. Use the “Add Animation” button for the others. - With an animation selected, click the grid icon Add frames from a Sprite Sheet and pick your PNG.
- Set Horizontal = frames per row (the widest row) and Vertical = number of rows. Check the grid lines match the sprites; use Separation/Offset if your sheet has padding (some packs use a 1–2 px gap).
- Click the frames of one row, in order, then Add N frame(s).
- Set the animation speed (FPS) and toggle Loop off for one-shot animations (hurt, death, attack).
- Repeat for each row, tick Autoplay on Load for
idle, and save the SpriteFrames as a.tres(right-click the property › Save) so other enemies can reuse it.
This is fine for one character. It gets tedious with 4 animations × 8 colours = 32 slicing passes, and it is easy to click a frame out of order.
Method 2 — generate the .tres with a script (best for many variants)
A SpriteFrames resource saved as .tres is a text file with three parts: one ext_resource pointing at the sheet, one AtlasTexture sub_resource per frame with its Rect2 region, and a [resource] block that lists the animations (frames, loop, name, speed). Here is what it looks like:
[gd_resource type="SpriteFrames" load_steps=19 format=3]
[ext_resource type="Texture2D" path="res://slime_forge/slimes/green/green_all.png" id="1_sheet"]
[sub_resource type="AtlasTexture" id="AtlasTexture_idle_0"]
atlas = ExtResource("1_sheet")
region = Rect2(0, 0, 16, 16)
...
[resource]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_idle_0")
}, ...],
"loop": true,
"name": &"idle",
"speed": 6.0
}, ...]
The script below writes exactly that for every row of a sheet. Save it as sheet_to_spriteframes.py (download), then run:
python3 sheet_to_spriteframes.py slime_all.png res://art/slime_all.png 16 16 idle:4:6:loop hop:6:10:loop hurt:2:8 death:5:10 > slime_spriteframes.tres
Arguments: the sheet on disk, its res:// path inside your project, frame width and height, then one name:frames:fps[:loop] per row from top to bottom. Drop the resulting file into your project and assign it to the AnimatedSprite2D's Sprite Frames.
#!/usr/bin/env python3
"""sheet_to_spriteframes.py - turn a sprite sheet into a Godot 4 SpriteFrames .tres
Each row of the sheet is one animation. Example:
python3 sheet_to_spriteframes.py slime_all.png res://art/slime_all.png 16 16 \
idle:4:6:loop hop:6:10:loop hurt:2:8 death:5:10 > slime_spriteframes.tres
Arguments: sheet file (to read nothing but check it exists), its res:// path,
frame width, frame height, then one name:frames:fps[:loop] per row, top to bottom.
MIT licence - Slime Forge.
"""
import os
import sys
def main(argv):
if len(argv) < 6:
sys.exit(__doc__)
sheet, res_path, fw, fh = argv[1], argv[2], int(argv[3]), int(argv[4])
if not os.path.exists(sheet):
sys.exit(f"sheet not found: {sheet}")
subs, anims = [], []
for row, spec in enumerate(argv[5:]):
parts = spec.split(":")
name, count, fps = parts[0], int(parts[1]), float(parts[2])
loop = len(parts) > 3 and parts[3] == "loop"
ids = []
for i in range(count):
sid = f"AtlasTexture_{name}_{i}"
subs.append(f'[sub_resource type="AtlasTexture" id="{sid}"]\n'
f'atlas = ExtResource("1_sheet")\n'
f'region = Rect2({i * fw}, {row * fh}, {fw}, {fh})\n')
ids.append(sid)
frames = ", ".join('{\n"duration": 1.0,\n"texture": SubResource("%s")\n}' % s for s in ids)
anims.append('{\n"frames": [%s],\n"loop": %s,\n"name": &"%s",\n"speed": %s\n}'
% (frames, "true" if loop else "false", name, repr(fps)))
out = [f'[gd_resource type="SpriteFrames" load_steps={len(subs) + 2} format=3]\n',
f'[ext_resource type="Texture2D" path="{res_path}" id="1_sheet"]\n']
out += subs
out.append("[resource]\nanimations = [%s]\n" % ", ".join(anims))
sys.stdout.write("\n".join(out))
if __name__ == "__main__":
main(sys.argv)
Notes. The output follows the text format Godot 4 itself writes for SpriteFrames (format=3, no uid: Godot adds one when it re-saves the file). The res:// path must match where the PNG really is; if you move it, Godot's Fix Dependencies dialog repairs the link. To loop through colour variants, call the script once per sheet in a shell loop.
Common problems
- The sprite “jitters” between animations: frames of different rows are not aligned on the same feet line. Keep the character's feet on the same pixel row in every cell and set the node's
offsetonce (e.g.Vector2(0, -8)for 16x16 so the node origin sits at the feet). - Death plays forever: loop is still on. Turn it off and connect
animation_finishedtoqueue_free(). - Frames bleed from the next cell: the sheet has padding; account for it in Separation (editor) or in the Rect2 maths (script).
- Everything is blurry: see Nearest filtering above.
Want it already done?
The free Animated Slime Enemies Pack (16x16, 8 colours) and Slime Forge DELUXE (16 colours + 32x32 King Slime boss, 4 €) ship a ready-made SpriteFrames .tres for every colour and an example scene, generated this way. For the enemy logic (patrol, hop, hurt flash, death), follow How to make a slime enemy in Godot 4; to compare other free packs, see Free slime sprite sheets: 11 packs compared.
Need the whole roster? The Dungeon Enemies bundle (6 € on itch.io, 13 € separately) has 16 slimes + a 32x32 King Slime boss, bats, skeletons and ghosts in 8 colours each, with Godot 4 SpriteFrames for every colour.
FAQ
Where is the 'Add frames from sprite sheet' button in Godot 4?
Select the AnimatedSprite2D, click its Sprite Frames property and choose New SpriteFrames, then click the SpriteFrames resource to open the SpriteFrames panel at the bottom. The grid icon in that panel's toolbar is 'Add frames from a Sprite Sheet'.
Why are my pixel-art sprites blurry in Godot 4?
Godot filters textures linearly by default. Set Project Settings > Rendering > Textures > Canvas Textures > Default Texture Filter to Nearest, or set the node's Texture > Filter to Nearest.
Can I generate a SpriteFrames .tres file with a script?
Yes. A .tres file is plain text: one ext_resource for the sheet, one AtlasTexture sub_resource per frame with its Rect2 region, and a resource block listing the animations with their frames, loop flag and speed. The script on this page writes it from a list of rows.
Should hurt and death animations loop?
No. Set loop to false for one-shot animations (hurt, death, attack) and listen to the animation_finished signal to know when they end; keep idle and walk/hop looping.
What is the difference between SpriteFrames and AnimationPlayer for sprite sheets?
SpriteFrames with AnimatedSprite2D is the simplest way to flip through frames at a fixed speed. AnimationPlayer with a Sprite2D's frame property is better when you also animate other properties (hitboxes, sounds, position) on the same timeline.