Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Godot 2d Sprites?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tipoli5890-godot-2d-sprites)
---
name: godot-2d-sprites
description: >-
Sprite frames into Godot: frames.json to SpriteFrames, AnimatedSprite2D, sheet slicing, pivots,
filtering and import for pixel art.
---
# godot-2d-sprites — frames from game-assets, in Godot
A `frames/1` set becomes a `SpriteFrames` resource written as text, one animation per clip, and
an `AnimatedSprite2D` seated so the set's pivot (the feet) sits on the node's position.
## Load what the situation needs
| The situation | Read |
|---|---|
| A frame folder with `frames.json` from `codex-visual` or `sprite-from-video`; "import these frames" | *The conversion* below, then `reference/spriteframes.md` §1-3 |
| The feet float or sink, the sprite jumps between animations, which way the pivot's y goes | `reference/spriteframes.md` §2 |
| A hand-drawn grid sheet with no `frames.json` | `reference/spriteframes.md` §3 (`--sheet`) |
| Playing, chaining a one-shot into a loop, footstep frames, syncing a run cycle to speed | `reference/spriteframes.md` §5 |
| Building the `SpriteFrames` inside Godot (runtime content, a tool script) | `reference/spriteframes.md` §6 · `resources/sprite_frames_builder.gd` |
| Pixel art that blurs or shimmers; what the `.import` file can and cannot set | `reference/pixel-art-import.md` |
| How big the courier draws; one scale for every set of a character | `reference/spriteframes.md` §4 · `reference/pixel-art-import.md` §3 |
| Proving a conversion without a window | `reference/spriteframes.md` §7 |
| Draw order, y-sorting, 2D lights, outlines | `godot-2d-rendering` |
| Bones and weighted parts instead of frames | `godot-2d-rig` |
| Animation trees and state machines over the clips | `godot-animation` |
## The conversion
```bash
python3 scripts/frames_to_spriteframes.py \
game/art/courier/courier_run=run game/art/courier/courier_land=land \
--out game/art/courier/courier.tres --scene game/art/courier/courier.tscn --node-name Courier
```
It writes, beside `--out`, inside the Godot project:
| File | What it is |
|---|---|
| `courier.tres` | the `SpriteFrames`: `run` at the run set's `fps_hint`, looping; `land` at its own, a one-shot. Each frame an `AtlasTexture` region of the sheet. Metadata `pivot_px`, `box_px`, `core_height_px`, `pixel_block_px` |
| `courier.png` | every frame packed into one sheet (`--layout files` keeps one texture per PNG instead) |
| `courier.png.import` | only for a pixel set and only when none exists: lossless, no mipmaps, 3D detection off |
| `courier.tscn` | an `AnimatedSprite2D` node named Courier: `centered = false`, `offset = -pivot_px`, nearest filtering for a pixel set |
Then import the project once (`godot --headless -l en --path game --import`) so the sheet is a
texture Godot can load. The script needs no Godot itself; it reads PNGs with the standard library.
Exit codes: 0 written · 1 refused (a usage error, a stamp other than `frames/1`, a `frames/1`
file missing a required key, a failed producer verdict without `--accept-failed`, a frame off the
canvas, a texture outside the project, a files layout over two canvases) · 3 a missing or
unreadable file.
## Decisions the converter makes, and why
1. **The pivot is converted, not copied.** frames/1 `pivot_norm` has its origin bottom-left, y
up. Godot textures are y down from the top-left, so `pivot_px = (x * W, (1 - y) * H)` and the
node gets `offset = -pivot_px` with `centered = false`. `SpriteFrames` has no per-animation
offset, so every animation in one resource must share a pivot: the atlas layout packs a mix of
canvases into one common box, the files layout refuses the mix.
2. **One animation per clip, its own rate.** `fps_hint` is the animation speed; `loop` is the
loop mode; `hold_last` needs nothing more than `loop: false`, because a finished animation
stops on its last frame and holds it.
3. **The producer's verdict is respected.** A set whose `verdict.ok` is false was failed by its
own gate; it is refused until the set is fixed or `--accept-failed` says otherwise.
4. **Paths stay relative.** Every texture is `path="courier.png"`, relative to the `.tres`, which
Godot resolves against the resource's folder; no `uid=` is written, so the files survive a
move inside the project.
5. **Filtering is a node or project setting, not an import setting.** The `.import` file sets
compression, mipmaps and the 3D switch; nearest sampling is `texture_filter = 1` on the node or
`rendering/textures/canvas_textures/default_texture_filter=0` for the project.
## Seating and playing
```gdscript
const SpriteFramesBuilder = preload("res://tools/sprite_frames_builder.gd")
@onready var courier: AnimatedSprite2D = $Courier
func swap_frames(frames: SpriteFrames) -> void:
SpriteFramesBuilder.seat(courier, frames) # re-applies the pivot from the metadata
func land() -> void:
courier.play(&"land")
await courier.animation_finished
courier.play(&"run")
```
- Facing left: `scale.x = -1` on the courier's parent `Node2D`, which mirrors about the pivot.
- Size: Godot 2D units are pixels; scale the character's root by
`world_height / core_height_px`, one factor for every set of the character.
- Playing the animation that is already playing does not restart it; `stop()` returns to frame
0, `pause()` keeps the frame.
## Checking it headless
Godot renders nothing headless, but the data can all be proved there:
- load the `.tres`; animation names, frame counts, speeds and loops match the folders;
- every `AtlasTexture` region is the box size, and `AtlasTexture.get_image` returns the source
frame's pixels (the pixel just above `pivot_px` is the one above the feet in every frame);
- the scene's `offset` is `-pivot_px`; a one-shot ends on its last frame with one
`animation_finished`.
`scripts/frames_to_spriteframes.py --selftest` does exactly that in a temp project (it needs
`GODOT_BIN`): two frame folders with different canvases and asymmetric pivots, a grid sheet, the
pixel `.import` read back after `--import`, the in-engine builder, and every refusal's exit
code. Judge a Godot run by its sentinel line and the absence of `ERROR:` and `SCRIPT ERROR:`
lines, never by its exit code (Godot exits 0 after errors; `godot-verify`).
## Discipline
- **Never hand-edit a frame's position to fix the feet.** The pivot comes from the asset side;
if it is wrong, fix `pivot_norm` there and convert again.
- **One canvas per files-layout resource**, one `reference_core_height_px` per character.
- **Keep previews out of the frame folder.** A GIF or APNG preview is not a frame; frames/1
lists the files, and the converter reads only those.
- **Re-convert, do not patch.** The `.tres` is generated; changing a speed by hand is lost on the
next conversion. Change `fps_hint` at the source and convert again.
- **Commit the `.import` files** beside the PNGs; never commit `.godot/`.
## Related skills
| Need | Skill |
|---|---|
| The frames themselves: generating, keying, cutting a sheet into frames/1 | `codex-visual` |
| Loops cut from video into frames/1 | `sprite-from-video` |
| Draw order, y-sorting, 2D lights, shaders on sprites | `godot-2d-rendering` |
| Skeletal 2D from a layered character | `godot-2d-rig` |
| Animation trees, blending, state machines | `godot-animation` |
| Running Godot headless and trusting the result | `godot-verify` |