Black Week: −40% Pixor is $19.99 $11.99 until 2 December, on itch.io →

A sprite in Godot 4, ready to play

Pixor can write a Godot SpriteFrames resource next to the sheet. Drop both into your project and an AnimatedSprite2D has every action and side as a named animation.

The chest opening, rendered with Pixor
First sprite: a treasure chest: the sheet this sample project renders

Sample project

First sprite: a treasure chest: the .pixor project and its library model (CC0). The sheet on the left is what it renders.

Beginner · about 10 minutes · or watch it in 71 seconds

1. A sprite to export

Open the first-sprite sample, or follow your first sprite to get there: the treasure chest with its Open and Close actions, and a ring of four cameras. Any model works the same way.

2. Add the Godot output

Open the Asset step. The Asset graph decides what Export writes. From its + menu, add File: Godot SpriteFrames.

Click Export in the header and choose a folder. Next to each other you get:

  • first-sprite.png, the sprite sheet (named after the project);
  • first-sprite.tres, a SpriteFrames resource that points at the sheet and lists every frame.

3. Copy both into Godot

Copy first-sprite.png and first-sprite.tres into your Godot project, side by side. The .tres loads the sheet from res://first-sprite.png, the top of the project. To keep sprites in a folder such as res://sprites/, edit the path at the top of the .tres to match. Godot imports the PNG when its window comes back into focus.

4. Make an AnimatedSprite2D

  1. In your scene, add an AnimatedSprite2D node.
  2. In its Inspector, find Sprite Frames and load first-sprite.tres (or drag the file onto the field).
  3. Under CanvasItem, open Texture and set Filter to Nearest. Without this, Godot smooths the pixels and the sprite looks soft.

To make nearest the default for every sprite, go to Project Settings → Rendering → Textures and set the default canvas texture filter to Nearest.

Open the SpriteFrames panel at the bottom of the editor. Each animation is named after the action and the side, in the form Action_Side: Open_South, Open_East, Close_North and so on. Every animation loops and keeps its frame holds. Pick one and press play to check it; untick looping for one-off actions such as Open.

5. Play it from a script

Attach a script to the node, or to its parent, and call play with an animation name:

extends AnimatedSprite2D

func open_towards(side: String) -> void:
	play("Open_" + side)

func _ready() -> void:
	open_towards("South")

For a character, build the name from the action and the direction it faces, such as "Walk_" + side.

6. Mirrored sides

If you rendered only one side of a pair, such as East without West, let Godot mirror it. Set flip_h on the node:

func face_west() -> void:
	flip_h = true
	play("Walk_East")

Set flip_h = false again when the character faces East. Mirroring swaps left and right hands, so render the West side too if that matters for your character.

7. Pixel-perfect placement

Pixor fixes the pivot to one pixel in every frame and every side, so the sprite does not drift when it changes animation. Place the node on whole pixels, and keep your camera zoom at whole numbers for the cleanest result.

Next

Questions

My sprite looks blurry in Godot. Why?

Godot filters textures linearly by default. Set the AnimatedSprite2D's Texture Filter to Nearest, or set the default for the whole project in Project Settings under Rendering, Textures.

Can I re-export after changing the model?

Yes. Export again to the same folder and copy both files over the old ones. The animation names stay the same, so your scripts keep working.

Which Godot version does this use?

This tutorial is written for Godot 4 and its AnimatedSprite2D node.

Read next

Try it on your own model, free in your browser, or get the full version.

Try in browser Get Pixor