AI sprite animation for a character you can play

By GamesByAI · Published · Updated · 30 sources

On this page

AI sprite animation starts with one character design and a plan for how it moves. You make the idle, walk and attack from that same reference, clean up the frames, then pack and play them. A good first frame only really helps if the character’s still recognizable in the next one.

Phaser, PixiJS and Canvas can all play sprite animation, but a catalog entry that names one of them doesn’t tell us how its frames were made. Metal Assault, for instance, actually draws its assets in code.

Making the art and picking a style is what the assets guide is for. This one starts once that art is approved and ends with a character who can idle, walk and attack. We checked the tool features, access and terms below on October 1, 2026.

Choose what you need to control

There are plenty of ways to get frames out of a model, and which one fits depends on what you need control over, whether that’s the pose, the appearance, the timing or a rig you can reuse.

Method Use it for What you supply What you still fix
Reference frame plus pose sheet A specific walk or attack silhouette Approved character and ordered pose drawings Anatomy, missing in-betweens and loop seam
Image-to-image, frame by frame A short move with precise poses The same reference plus one target pose per frame Design drift and inconsistent lighting
Video-to-frames Broad, flowing motion A still character and a motion prompt or reference Camera motion, blur, background and usable pose selection
Skeletal 2D A painted character with reusable body parts Separate images for torso, head, limbs and equipment Part overlap, pivots, drawing order and keyframes
Procedural A bobbing idle, squash, recoil or simple limbs A fixed sprite or drawing functions Timing, readable contact poses and collision behavior

None of these promises that a generator will hand you a finished cycle, so try one move before you pay for a whole month of retries.

Check output rights separately from free access

Free access and the right to ship what you make aren’t the same thing, so check the plan before you generate a whole moveset.

Tool Animation and output Free access and cost Output terms
PixelLab New Animate with Text: 4-16 frames, even counts, input first frame preserved, transparent option (docs). No subscription required. A 64 by 64 animation costs 1 generation (costs). Limited trial, some tools excluded (FAQ). Commercial use allowed. No model training on output without permission; Open RAIL-M compliance required (terms).
Ludo.ai Still image, keyframes or transferred motion to a PNG grid, PNG frame ZIP, sheet plus JSON, GIF or MP4 (sprite docs) 30 starting credits, no card (Ludo). Free sheet downloads are watermarked (docs). Indie is $15/month billed annually, $180/year (pricing) Users retain rights to use, share and monetize content (account docs)
Scenario Reference-guided images (docs). Its sprite workflow converts a still to video, then extracts and packs poses (tutorial). Pricing page advertises 50 free daily credits, no card. Generation costs depend on the model (pricing). Free output: personal/evaluation only. Paid plans allow commercial use without royalties. Images include PNG; videos include MP4 (pricing).

PixelLab also has Pose to image, which takes a pose skeleton and an initial image, and Image to image (Depth), which uses a reference to guide the shape. Both are handy ways to build individual target frames. Keep the settings fixed between frames and change only the pose, on purpose.

1. Lock the reference and plan the poses

Approve one frame at the size it’ll appear in the game, then draw a pose plan before you ask for the rest. Use that same reference for the idle, walk and attack, and don’t let the finished walk become the new design reference for the attack.

Leave room for the widest attack pose, and if it won’t fit, enlarge every frame’s canvas together. Our worked example keeps the ground line and the horizontal center fixed.

Reference setting Value
Transparent canvas 64 by 64 pixels
Ground line Y=60
Horizontal center X=32

Save a small spec alongside the reference, like this one.

hero-reference.png is the approved design.
Side view, facing right; fixed camera and scale.
64 x 64 canvas; center X=32; ground Y=60.
Keep the same head size, costume, weapon and outline.
Palette: [paste your approved colors].
Idle: 4 frames. Walk: 8 frames. Attack: 6 frames.
Transparent background; no labels or sheet dividers.

Those are example settings to adapt, not a format any model requires. Then plan each action on its own.

Action Pose plan Starting timing
Idle Neutral, small inhale, peak, settle; feet fixed 4 frames at 6 fps
Walk Right contact, down, passing, up; left contact, down, passing, up 8 frames at 10 fps
Attack Ready, anticipation, windup, impact, follow-through, recovery 6 frames at 12 fps; play once

For a walk, the body moves in place, because the game is what moves the character across the level. The two contact poses should read differently too, since mirrored arms alone don’t make a stride.

Pair the reference with a pose plan

Sketch the pose sheet with simple shapes, one silhouette per frame in order, with the feet and body on the same grid, and supply it as pose guidance where the tool supports that. A picture with eight poses in it won’t necessarily come back as eight neat output frames.

PixelLab documents skeleton guidance, while Ludo documents first, middle and final keyframes (PixelLab, Ludo). Those controls suit contact poses or an attack’s windup, impact and recovery, and the generated in-betweens still need your own check.

A motion prompt for the walk can look like this.

Animate the attached approved character walking in place, facing right. Use the attached pose plan for the order of the contacts and passing poses. Keep the camera, character size, costume, weapon and palette fixed. No forward travel, camera movement, background or motion blur. The last pose must lead naturally into the first; do not duplicate the first frame at the end.

Generate each pose against the original reference

Generate each target pose against the original character reference, with the pose sketch guiding the structure and the approved image guiding the appearance. Scenario’s reference controls let you adjust how much influence the reference has, though its docs say the result also depends on the model, prompt and settings (Scenario).

For the attack’s impact frame, you could try something like this.

Keep the attached character’s design unchanged. Draw only the impact pose from the attached sketch, facing right on the same canvas. Preserve head size, clothing colors, weapon length and the ground line. No added effects; the attack must remain readable without them.

If a frame changes the costume or anatomy, repair it or draw the correction yourself. Feed an altered frame into the next generation and the mistake becomes part of your reference, and the design drifts from there.

2. Extract frames or animate fixed parts

You don’t even have to generate every frame on its own. Video, a 2D rig and procedural motion are all ways around that.

Extract one complete cycle from video

Generate one action with a locked camera, then pick a short section you can use. Scenario’s tutorial takes a detour through video, turning a still into a clip, pulling key poses out with screenshots or a video editor and then aligning them into a sheet. Ludo also lets you download individual PNG frames and video (Ludo).

  1. Ask for one in-place action, no camera movement and a plain contrasting background.

  2. Find two matching contact poses with one complete walk cycle between them, and stop before the repeated contact frame.

  3. Sample evenly spaced frames for a first pass. For an attack, keep the anticipation, impact and recovery, even if they need unequal holds later.

  4. Remove the background, clean edge halos, and align every frame to the approved canvas. Check it on both dark and light backgrounds.

  5. Throw out blurred limbs and changes in scale, because cropping can’t undo a camera turn.

And look at the exact small images you’ll ship, not just the generated video’s preview.

Rig fixed drawings instead of regenerating limbs

Another route is to generate or cut out the character’s parts once, then rig those fixed drawings in Spine. Paint the hidden overlap behind the shoulders, elbows and knees so rotating a limb won’t reveal a hole. Keep left and right limbs separate, put the joints where they bend, and give the weapon its own attachment.

Spine’s purchase page lists Essential at $69 and Professional at $379, and you need Enterprise once annual revenue reaches $500,000. Saving and exporting need a paid license, while the free trial is only for evaluation and grants no runtime integration rights (purchase, license). Those are the editor and runtime terms, though, and the generated drawings need usable output rights of their own.

Keyframe the idle, walk and attack on the same rig. You can export JSON or binary data for a Spine runtime, or bake a PNG image sequence and use the grid examples below (Spine export). Essential leaves out meshes and other advanced features, so a rig that uses them needs the edition that has them (purchase).

Pick this route when you want to reuse a drawing across a lot of poses. For pixel art, look at the rotated edges at native size before you commit, because you may prefer hand-corrected raster frames.

Let code move the fixed art

You can also keep the art fixed and let code do the moving. Start with a small idle bob, a short recoil or limbs rotating around fixed joints. Use elapsed time to compute a repeating phase, like Math.sin(seconds * Math.PI * 2), and round positions when the art needs whole pixels.

Metal Assault is a nice concrete example from our catalog. Its entry, sourced from its repository, says the sprites, levels and audio all come from code and that it runs on Canvas. That backs up the method, though it doesn’t point to any particular animation formula.

We tried four of these on our mascot

On October 1, 2026 we tried to get Player Two, the GamesByAI mascot, walking, starting every try from the same waving picture. Claude Code (Claude Opus 5.5) wrote the code, while the image tool in the Codex CLI drew the images.

  • Code only. Claude Code drew the character with canvas calls and no image files. It walked, turned and jumped on the first run, but the body came out as an upright handheld console instead of the wide controller in the reference. It never saw the result, and it said “I had no browser here and no way to execute the page.”
  • One sheet in one go. Each of three tries at an eight-frame walk sheet came back in under a minute, and every frame kept the antenna, the face, the d-pad and both buttons. But while the prompt asked for a profile, every frame came back turned toward the viewer, and oddly enough, one sheet gave the face a single eye. Played on the grid, the character slid sideways inside its cell, with its soles up to nine pixels apart.
  • Frame by frame against the reference. Four poses, generated one at a time against the reference, all stayed on model. Each picture put the character in a different spot, though, and you can see it in the loop, which kind of hops until you align the frames the way step 3 describes.
  • Fixed parts and a code rig. The image tool drew the body, one arm, one leg and the antenna once. Claude Code then cut the limbs at their joints and moved them in code, so the face, d-pad and buttons are the same pixels in every frame. The limbs came out thin at the scale it picked by eye, without ever running the page. Turning around mirrors the art, and in a funny side effect, the d-pad swaps sides.

The rig was the only version that kept the reference body in every frame and also walked and jumped under keyboard control, so Claude Code built a short platform level around it. If you’re curious, the three versions that run in a browser are playable as the AI left them.

3. Reject drift before packing

Check every frame against the approved reference, then play the cycle at the size and speed it’ll have in the game, because packing doesn’t fix a bad frame.

  • Design. The face, costume, colors, outline and weapon stay the same. Count visible fingers or limbs where they matter.

  • Scale. Head and torso dimensions stay fixed unless the pose squashes them on purpose. Align a reference overlay instead of auto-resizing each pose to its bounding box.

  • Ground and origin. Planted feet stay on the baseline, and airborne poses move relative to it. The canvas origin doesn’t move.

  • Silhouette. Each contact, anticipation and impact pose reads at game size, which a solid-color silhouette view makes easy to check.

  • Loop. Scrub the last-to-first transition and remove an accidental duplicate endpoint. Don’t append reverse playback to disguise a broken walk.

  • Edges. You want real transparency, with no background fragments, no clipped sword tip and no light halo on a dark scene.

  • Timing. Watch it slowly to find mistakes, then at target speed to judge the action. Hold anticipation or recovery on purpose rather than padding with blank frames.

Keep movement and hitboxes in game coordinates, so a longer attack drawing doesn’t quietly make the character’s standing collision box bigger. For hit stop and the rest of the timing around a hit, see the game-feel guide.

4. Lay out and slice the sheet

Use a uniform grid for your first moveset, or an atlas when you need irregular sizes and trimmed space. Phaser’s texture docs explain the difference, which is that a sheet has uniform cells while an atlas has named frames at different sizes and positions.

Keep exporter and playback on the same grid

Arrange the accepted frames in reading order, leave unused cells transparent and keep them out of playback. Your exporter and your playback code should agree on the same grid.

Sheet setting Value
PNG dimensions 512 by 192 pixels
Columns and rows Eight columns, three rows
Cell dimensions 64 by 64 pixels
Margin and spacing Zero
Row Animation Global frame indices Unused cells
0 Idle 0-3 4-7
1 Walk 8-15 None
2 Attack 16-21 22-23

Numbering starts at zero. For a frame index i, this is where the source rectangle starts.

const sx = margin + (i % columns) * (frameWidth + spacing);
const sy = margin + Math.floor(i / columns) * (frameHeight + spacing);

When you slice in an editor, enter the actual cell dimensions and the correct outer margin and gap, then count the sliced frames and preview the first and last cell of each row. If a generator painted grid lines, those are part of the pixels too, so remove them before slicing.

Preserve frame sizes and offsets in an atlas

Pack individual files named idle_00.png, walk_00.png, attack_00.png and so on, pick the export format for your engine and keep the frame names predictable. TexturePacker has a 7-day full-feature trial and a free Essential mode, but advanced settings need a license, and in free-mode output they can actually turn sprites red (licensing).

Its settings cover PNG output, frame names, trimming, rotation, padding and extrusion. A sensible start is rotation off, two pixels between shapes and one pixel of edge extrusion, and then you check the real atlas at game size. Position the frames from the matching metadata.

A trimmed frame has three separate rectangles or sizes to keep track of.

Field Meaning Example
frame Packed rectangle in the atlas PNG { x: 2, y: 2, w: 36, h: 54 }
sourceSize Original full canvas { w: 64, h: 64 }
spriteSourceSize Placement of the trimmed drawing within that canvas { x: 14, y: 6, w: 36, h: 54 }

For that example, keep trimmed: true and rotated: false. It’s easy to miss, but if you throw away the original size and offset, a tight crop can make a character who’s standing still jump when its arm extends. Phaser documents these fields, and PixiJS textures keep both the original and trimmed dimensions (Phaser, PixiJS).

5. Play the grid in Phaser 3/4

In Phaser, load the PNG with spritesheet, define the three ranges and play the attack with zero repeats. The code uses the APIs from Phaser’s textures, animations and completion events docs, and pixelArt turns on nearest sampling and rounded positions (config).

Use it in a JavaScript module in a project with Phaser installed, serve your packed sheet at /art/hero-grid.png and add <div id="game"></div> to the page. If you’d like an agent to set up that project, see Phaser with AI.

import Phaser from 'phaser';

class Demo extends Phaser.Scene {
  preload() {
    this.load.spritesheet('hero', '/art/hero-grid.png', {
      frameWidth: 64, frameHeight: 64, margin: 0, spacing: 0
    });
  }
  create() {
    const image = this.textures.get('hero').getSourceImage();
    if (image.width !== 512 || image.height !== 192) {
      throw new Error('Expected a 512 x 192 hero sheet');
    }
    for (const [key, start, end, fps, repeat] of [
      ['idle', 0, 3, 6, -1],
      ['walk', 8, 15, 10, -1],
      ['attack', 16, 21, 12, 0]
    ]) {
      this.anims.create({ key, frameRate: fps, repeat,
        frames: this.anims.generateFrameNumbers('hero', { start, end }) });
    }
    const hero = this.add.sprite(160, 180, 'hero', 0)
      .setOrigin(0.5, 60 / 64).setScale(2);
    hero.play('idle');
    hero.on('animationcomplete-attack', () => hero.play('idle'));
    this.hero = hero;
  }
  setMotion(name) { // call from your input/state code
    if (!['idle', 'walk', 'attack'].includes(name)) throw new Error(name);
    const state = this.hero.anims;
    if (state.currentAnim?.key === 'attack' && state.isPlaying) return;
    this.hero.play(name, true); // don't restart a move already playing
  }
}

const game = new Phaser.Game({
  type: Phaser.AUTO, width: 320, height: 240,
  parent: 'game', pixelArt: true, scene: Demo
});

Call game.scene.getScenes(true)[0].setMotion('walk') when movement starts, setMotion('idle') when it stops and setMotion('attack') for an attack. The example goes back to idle when the attack finishes, though a full game might pick walk instead if the input’s still held.

For an atlas, swap the grid loader for this.load.atlas('hero', '/art/hero-atlas.png', '/art/hero-atlas.json'). Then swap the numeric frame helper for this.anims.generateFrameNames('hero', { prefix: 'walk_', start: 0, end: 7, zeroPad: 2, suffix: '.png' }), then do the same for idle and attack. Start the sprite on 'idle_00.png'. Both frame helpers are documented in Phaser’s animation guide.

6. Play the grid in PixiJS v8

In PixiJS, load the image as a texture, then make a new texture view for each cell from the image’s source. That works because PixiJS keeps Texture separate from TextureSource (textures), and the asynchronous Application setup and AnimatedSprite take care of rendering and playback.

Use a JavaScript module in a project with pixi.js v8 installed. Each frame object below has its own explicit duration in milliseconds, as the FrameObject API defines it.

import { Application, Assets, Texture, Rectangle, AnimatedSprite } from 'pixi.js';

const app = new Application();
await app.init({ width: 320, height: 240, roundPixels: true });
document.body.appendChild(app.canvas);
const base = await Assets.load('/art/hero-grid.png');
if (base.width !== 512 || base.height !== 192) {
  throw new Error('Expected a 512 x 192 hero sheet');
}
base.source.scaleMode = 'nearest';

function frames(start, count, fps) {
  return Array.from({ length: count }, (_, n) => {
    const i = start + n;
    const texture = new Texture({ source: base.source,
      frame: new Rectangle((i % 8) * 64, Math.floor(i / 8) * 64, 64, 64) });
    return { texture, time: 1000 / fps };
  });
}
const clips = {
  idle: frames(0, 4, 6), walk: frames(8, 8, 10), attack: frames(16, 6, 12)
};
const hero = new AnimatedSprite(clips.idle);
hero.anchor.set(0.5, 60 / 64);
hero.position.set(160, 180);
hero.scale.set(2);
hero.animationSpeed = 1;
app.stage.addChild(hero);
let motion;
function setMotion(name) {
  if (!clips[name]) throw new Error(name);
  if (name === motion || (motion === 'attack' && hero.playing)) return;
  motion = name;
  hero.textures = clips[name];
  hero.loop = name !== 'attack';
  hero.gotoAndPlay(0);
}
hero.onComplete = () => setMotion('idle');
setMotion('idle');

Call setMotion('walk'), setMotion('idle') or setMotion('attack') from your game state. onComplete runs for the non-looping attack and switches back to idle, and a walk that’s already playing doesn’t restart on every update.

For an atlas, const sheet = await Assets.load('/art/hero-atlas.json') loads the sheet the JSON describes. Build each clip from names in an explicit order, like sheet.textures['walk_00.png'] through 'walk_07.png', and wrap them as { texture, time }. If the JSON includes animation definitions, you also get sheet.animations.walk (AnimatedSprite). Just keep the PNG path in the JSON correct.

7. Play the grid in plain Canvas

With no library at all, you crop each cell with the nine-argument drawImage call and advance by elapsed time, not by one animation frame per screen refresh. MDN documents drawImage, image decoding and animation timing.

Add <canvas id="game" width="320" height="240"></canvas> to the page and run this as a module, with image smoothing turned off for pixel art.

const canvas = document.querySelector('#game');
const ctx = canvas.getContext('2d');
if (!ctx) throw new Error('Canvas 2D is unavailable');
const sheet = new Image();
sheet.src = '/art/hero-grid.png';
await sheet.decode();
if (sheet.naturalWidth !== 512 || sheet.naturalHeight !== 192) {
  throw new Error('Expected a 512 x 192 hero sheet');
}
ctx.imageSmoothingEnabled = false;
const clips = {
  idle: { start: 0, count: 4, fps: 6, loop: true },
  walk: { start: 8, count: 8, fps: 10, loop: true },
  attack: { start: 16, count: 6, fps: 12, loop: false }
};
let motion = 'idle', elapsed = 0, last;
function setMotion(name) {
  if (!clips[name]) throw new Error(name);
  if (name === motion || motion === 'attack') return;
  motion = name;
  elapsed = 0;
}
function tick(now) {
  elapsed += last === undefined ? 0 : Math.min(now - last, 100);
  last = now;
  let clip = clips[motion];
  let n = Math.floor(elapsed * clip.fps / 1000);
  if (!clip.loop && n >= clip.count) {
    motion = 'idle'; elapsed = 0; clip = clips.idle; n = 0;
  }
  const i = clip.start + (n % clip.count);
  const sx = (i % 8) * 64, sy = Math.floor(i / 8) * 64;
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  // Anchor: sheet point (32, 60) sits at game point (160, 180).
  ctx.drawImage(sheet, sx, sy, 64, 64, 160 - 32 * 2, 180 - 60 * 2, 128, 128);
  requestAnimationFrame(tick);
}
requestAnimationFrame(tick);

Call the same three setMotion names from your input code. The example caps a single elapsed-time step at 100 ms, so coming back from a hidden tab doesn’t skip the whole attack. Decide how your game should pause, and if it should freeze entirely, reset last when it resumes.

For an unrotated, trimmed atlas, crop frame and draw at x - originX * scale + spriteSourceSize.x * scale, with the matching Y calculation, and multiply the packed width and height by the scale. This simple path needs atlas rotation turned off, unless you write rotated-frame handling yourself.

Check the character in the game

Switch between idle, walk and attack against a visible ground line. Attack a bunch of times in a row, hold movement during an attack, stop moving and come back after a tab switch. The character’s scale and origin should stay fixed, and every attack should finish exactly once.

In our catalog, Vibe Party has the combination this guide is about. Its creator’s submission says it was made with Codex on Phaser and uses AI-generated characters, backgrounds and assets, though it doesn’t name the art model or say how the animation frames were made. The Phaser, PixiJS and Canvas hubs link more games on each runtime.

It’s really worth getting one idle, walk and attack you’ve accepted before adding directions, and keep the reference, pose plan, prompts, original frames, sheet layout and tool terms together in one place. If it turns out the character needs a 3D skeleton, AI 3D animation for games picks up from there, and if the base art needs work, go back to the assets guide.

Games to look at

Questions

How do I keep an AI sprite animation consistent?

Reuse one approved character reference, fixed proportions and a pose plan for every animation, and compare each generated frame against that reference before you pack it. Align the canvas and ground line, and throw out frames that change the costume, palette or silhouette instead of hiding them with extra frames.

Can I generate sprite animations for free?

Only up to a point. PixelLab offers a trial, and its new animation tool uses generations without needing a subscription. Ludo gives you 30 starting credits, but free sheet downloads are watermarked, and Scenario restricts free outputs to personal and evaluation use.

Should I use a sprite sheet or a texture atlas?

Use a plain grid when every frame has the same canvas size, and an atlas when you want to pack frames of different sizes or trim transparent space. With an atlas, keep the original dimensions and trim offsets in the metadata so the character's origin stays fixed.

Can I load the same sprite sheet in Phaser and PixiJS?

Yes. Phaser splits a uniform grid with its spritesheet loader, while in PixiJS v8 you create a Texture for each cell or load an atlas JSON. The examples on this page use one 512 by 192 PNG with 64-pixel cells in both libraries and in plain Canvas.