phaserjs/phaser/animations
Claude Code and agent skill by phaserjs/phaser
- community
Checking that the SKILL.md file is still in the repository.
Use this skill when creating or controlling sprite animations in Phaser 4. Covers spritesheets, atlases, AnimationManager, AnimationState, play/stop/chain, frame callbacks, and animation events. Triggers on: sprite animation, spritesheet, play animation, animation frames.
Install
npx vskill@latest install phaserjs/phaser/animationsSKILL.md
The same SKILL.md was published earlier as phaserjs/phaser/animations.
Phaser 4 -- Sprite Animations
AnimationManager (global), AnimationState (per-sprite), creating animations from spritesheets and atlases, playing/pausing/chaining, animation events, frame callbacks.
Related skills: ../sprites-and-images/SKILL.md, ../loading-assets/SKILL.md
Quick Start
Core Concepts
AnimationManager vs AnimationState
Phaser has two distinct animation objects:
| Aspect | AnimationManager | AnimationState | |
|---|---|---|---|
| Access | this.anims (in a Scene) or this.game.anims | sprite.anims | |
| Scope | Global -- shared across all scenes | Per-sprite instance | |
| Purpose | Create/store animation definitions | Control playback on one Game Object | |
| Class | Phaser.Animations.AnimationManager | Phaser.Animations.AnimationState |
The AnimationManager is a singleton owned by the Game. Animations registered there are available in every Scene. The AnimationState lives on each Sprite and handles playback for that specific object.
An Animation is a sequence of AnimationFrame objects plus timing data. Created via this.anims.create(config) (global) or sprite.anims.create(config) (local to one sprite).
Local vs Global Animations
When sprite.anims.play(key) is called, it first checks for a local animation with that key, then falls back to the global AnimationManager. Use local for sprite-specific animations; use global when shared across sprites.
Common Patterns
Spritesheet Animation
Use generateFrameNumbers for spritesheets (numeric frame indices).
generateFrameNumbers config:
start(default0) -- first frame indexend(default-1, meaning last frame) -- final frame indexfirst-- a single frame to prepend before the rangeframes-- explicit array of frame indices (overrides start/end)
Atlas Animation
Use generateFrameNames for texture atlases (string-based frame names).
generateFrameNames config:
prefix-- prepended to each frame numbersuffix-- appended after each frame numberstart,end-- numeric rangezeroPad-- left-pad numbers to this length with zerosframes-- explicit array of frame numbers (overrides start/end)
If you call generateFrameNames(key) with no config, it returns all frames from the atlas.
String as Frames
Pass a texture key string as frames to use all frames from that texture, sorted numerically by default. Set sortFrames: false to disable sorting.
Yoyo and Repeat
When yoyo is true, the animation plays forward then reverses. The full cycle counts as one play.
Chaining Animations
Chaining is per-sprite. Chained animations start after animationcomplete or animationstop. An animation with repeat: -1 never completes -- call stop() to trigger the chain.
Playing in Reverse
playReverse sets forward = false and inReverse = true. The reverse() method toggles direction mid-playback.
Play Variants
Animation Mixing
Adds a transition delay between two specific animations, set globally on the AnimationManager.
Mix delays only apply with sprite.play(), not playAfterDelay or playAfterRepeat.
Pause, Resume, and Stop
All stop methods fire animationstop (not animationcomplete). Chained animations trigger after stop.
Animation Events
Available events: animationstart, animationcomplete, animationcomplete-{key}, animationupdate, animationstop, animationrepeat, animationrestart. All share the same callback signature: (animation, frame, gameObject, frameKey).
Frame-Level Callbacks via animationupdate
Per-Frame Duration
Individual frames can have a duration (ms) that is added to the base msPerFrame.
Visibility, Random Start, and TimeScale
Staggered Playback
JSON Export and Import
Modifying Animation Frames at Runtime
Aseprite Support
Configuration Reference
AnimationConfig (used with this.anims.create())
| Property | Type | Default | Description | |
|---|---|---|---|---|
key | string | -- | Unique identifier for the animation | |
frames | string or AnimationFrame[] | [] | Texture key string (uses all frames) or array of frame config objects | |
sortFrames | boolean | true | Numerically sort frames when using a string key | |
defaultTextureKey | string | null | Fallback texture key if not set per-frame | |
frameRate | number | 24 | Playback rate in frames per second (used if duration is null) | |
duration | number | null | Total animation length in ms (derives frameRate if set) | |
skipMissedFrames | boolean | true | Skip frames when lagging behind | |
delay | number | 0 | Delay before playback starts (ms) | |
repeat | number | 0 | Times to repeat after first play (-1 = infinite) | |
repeatDelay | number | 0 | Delay before each repeat (ms) | |
yoyo | boolean | false | Reverse back to start before repeating | |
showBeforeDelay | boolean | false | Show first frame immediately during delay period | |
showOnStart | boolean | false | Set visible=true when animation starts | |
hideOnComplete | boolean | false | Set visible=false when animation completes | |
randomFrame | boolean | false | Start from a random frame |
PlayAnimationConfig (used with sprite.play())
All AnimationConfig timing properties are available, plus:
| Property | Type | Default | Description | |
|---|---|---|---|---|
key | string or Animation | -- | Animation key or instance to play | |
startFrame | number | 0 | Frame index to begin playback from | |
timeScale | number | 1 | Speed multiplier for this playback |
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/animations/SKILL.md
Popularity
- Repository stars
- 39,633
- Repository forks
- 7,130
- 7-day trend score
- 53
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 May 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/phaserjs/phaser/animations)