[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M783T1JHNEVQH8P1K49D0835":3,"skill-same:01M783T1JHNEVQH8P1K49D0835":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M783T1JHNEVQH8P1K49D0835","animations",null,"Use this skill when creating or controlling sprite animations in Phaser 4. Covers spritesheets, atlases, AnimationManager, AnimationState, play\u002Fstop\u002Fchain, frame callbacks, and animation events. Triggers on: sprite animation, spritesheet, play animation, animation frames.","Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fskills_sh\u002Fs\u002Fskills-sh_phaserjs_phaser_animations\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: animations\ndescription: \"Use this skill when creating or controlling sprite animations in Phaser 4. Covers spritesheets, atlases, AnimationManager, AnimationState, play\u002Fstop\u002Fchain, frame callbacks, and animation events. Triggers on: sprite animation, spritesheet, play animation, animation frames.\"\n---\n\n# Phaser 4 -- Sprite Animations\n\n> AnimationManager (global), AnimationState (per-sprite), creating animations from spritesheets and atlases, playing\u002Fpausing\u002Fchaining, animation events, frame callbacks.\n\n**Related skills:** ..\u002Fsprites-and-images\u002FSKILL.md, ..\u002Floading-assets\u002FSKILL.md\n\n---\n\n## Quick Start\n\n```js\n\u002F\u002F In preload -- load a spritesheet\nthis.load.spritesheet('explosion', 'explosion.png', {\n    frameWidth: 64,\n    frameHeight: 64\n});\n\n\u002F\u002F In create -- define a global animation\nthis.anims.create({\n    key: 'explode',\n    frames: this.anims.generateFrameNumbers('explosion', { start: 0, end: 11 }),\n    frameRate: 24,\n    repeat: 0\n});\n\n\u002F\u002F Play it on a sprite\nconst sprite = this.add.sprite(400, 300, 'explosion');\nsprite.play('explode');\n```\n\n---\n\n## Core Concepts\n\n### AnimationManager vs AnimationState\n\nPhaser has two distinct animation objects:\n\n| Aspect | AnimationManager | AnimationState |\n|---|---|---|\n| Access | `this.anims` (in a Scene) or `this.game.anims` | `sprite.anims` |\n| Scope | Global -- shared across all scenes | Per-sprite instance |\n| Purpose | Create\u002Fstore animation definitions | Control playback on one Game Object |\n| Class | `Phaser.Animations.AnimationManager` | `Phaser.Animations.AnimationState` |\n\nThe 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.\n\nAn `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).\n\n### Local vs Global Animations\n\nWhen `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.\n\n```js\n\u002F\u002F Global animation -- available to all sprites\nthis.anims.create({ key: 'walk', frames: 'player_walk', frameRate: 12, repeat: -1 });\n\n\u002F\u002F Local animation -- only on this sprite\nsprite.anims.create({ key: 'walk', frames: 'npc_walk', frameRate: 10, repeat: -1 });\n\n\u002F\u002F This plays the LOCAL version because local takes priority\nsprite.play('walk');\n```\n\n---\n\n## Common Patterns\n\n### Spritesheet Animation\n\nUse `generateFrameNumbers` for spritesheets (numeric frame indices).\n\n```js\nthis.load.spritesheet('dude', 'dude.png', { frameWidth: 32, frameHeight: 48 });\n\n\u002F\u002F All frames\nthis.anims.create({\n    key: 'run',\n    frames: this.anims.generateFrameNumbers('dude', { start: 0, end: 7 }),\n    frameRate: 10,\n    repeat: -1\n});\n\n\u002F\u002F Custom frame sequence\nthis.anims.create({\n    key: 'idle',\n    frames: this.anims.generateFrameNumbers('dude', { frames: [0, 1, 2, 1] }),\n    frameRate: 6,\n    repeat: -1\n});\n```\n\n`generateFrameNumbers` config:\n- `start` (default `0`) -- first frame index\n- `end` (default `-1`, meaning last frame) -- final frame index\n- `first` -- a single frame to prepend before the range\n- `frames` -- explicit array of frame indices (overrides start\u002Fend)\n\n### Atlas Animation\n\nUse `generateFrameNames` for texture atlases (string-based frame names).\n\n```js\nthis.load.atlas('gems', 'gems.png', 'gems.json');\n\nthis.anims.create({\n    key: 'ruby_sparkle',\n    frames: this.anims.generateFrameNames('gems', {\n        prefix: 'ruby_',\n        start: 1,\n        end: 6,\n        zeroPad: 4   \u002F\u002F produces ruby_0001 through ruby_0006\n    }),\n    frameRate: 12,\n    repeat: -1\n});\n```\n\n`generateFrameNames` config:\n- `prefix` -- prepended to each frame number\n- `suffix` -- appended after each frame number\n- `start`, `end` -- numeric range\n- `zeroPad` -- left-pad numbers to this length with zeros\n- `frames` -- explicit array of frame numbers (overrides start\u002Fend)\n\nIf you call `generateFrameNames(key)` with no config, it returns all frames from the atlas.\n\n### String as Frames\n\nPass a texture key string as `frames` to use all frames from that texture, sorted numerically by default. Set `sortFrames: false` to disable sorting.\n\n```js\nthis.anims.create({ key: 'walk', frames: 'player_walk', frameRate: 12, repeat: -1 });\n```\n\n### Yoyo and Repeat\n\n```js\nthis.anims.create({\n    key: 'pulse',\n    frames: this.anims.generateFrameNumbers('orb', { start: 0, end: 5 }),\n    frameRate: 10,\n    yoyo: true,       \u002F\u002F plays forward then backward\n    repeat: -1,       \u002F\u002F -1 = forever\n    repeatDelay: 500   \u002F\u002F ms pause between each repeat cycle\n});\n```\n\nWhen `yoyo` is true, the animation plays forward then reverses. The full cycle counts as one play.\n\n### Chaining Animations\n\n```js\nsprite.play('attack');\nsprite.chain('idle');                        \u002F\u002F play idle after attack completes\nsprite.chain(['fall', 'land', 'idle']);       \u002F\u002F chain multiple\nsprite.anims.chain();                        \u002F\u002F clear the chain queue\n```\n\nChaining is per-sprite. Chained animations start after `animationcomplete` or `animationstop`. An animation with `repeat: -1` never completes -- call `stop()` to trigger the chain.\n\n### Playing in Reverse\n\n```js\n\u002F\u002F Play an animation from last frame to first\nsprite.playReverse('walk');\n\n\u002F\u002F Reverse direction mid-playback\nsprite.anims.reverse();\n```\n\n`playReverse` sets `forward = false` and `inReverse = true`. The `reverse()` method toggles direction mid-playback.\n\n### Play Variants\n\n```js\nsprite.play('walk', true);                   \u002F\u002F ignoreIfPlaying = true\nsprite.anims.playAfterDelay('walk', 1000);   \u002F\u002F play after 1s delay\nsprite.anims.playAfterRepeat('walk', 2);     \u002F\u002F play after current anim repeats 2x\n```\n\n### Animation Mixing\n\nAdds a transition delay between two specific animations, set globally on the AnimationManager.\n\n```js\nthis.anims.addMix('idle', 'walk', 200);\nthis.anims.addMix('walk', 'idle', 300);\n\nsprite.play('idle');\nsprite.play('walk');   \u002F\u002F 200ms mix delay applied automatically\n\nthis.anims.removeMix('idle', 'walk');   \u002F\u002F remove specific pair\nthis.anims.removeMix('idle');           \u002F\u002F remove all mixes for 'idle'\n```\n\nMix delays only apply with `sprite.play()`, not `playAfterDelay` or `playAfterRepeat`.\n\n### Pause, Resume, and Stop\n\n```js\nsprite.anims.pause();                 \u002F\u002F pause per-sprite\nsprite.anims.resume();                \u002F\u002F resume per-sprite\nthis.anims.pauseAll();                \u002F\u002F global pause\nthis.anims.resumeAll();               \u002F\u002F global resume\n\nsprite.anims.stop();                  \u002F\u002F stop immediately\nsprite.anims.stopAfterDelay(2000);    \u002F\u002F stop after 2 seconds\nsprite.anims.stopAfterRepeat(1);      \u002F\u002F stop after 1 more repeat\nsprite.anims.stopOnFrame(frame);      \u002F\u002F stop when a specific frame is reached\n```\n\nAll stop methods fire `animationstop` (not `animationcomplete`). Chained animations trigger after stop.\n\n### Animation Events\n\n```js\nsprite.on('animationcomplete', (anim, frame, gameObject, frameKey) => {\n    console.log('completed:', anim.key);\n});\n\n\u002F\u002F Key-specific complete -- only fires for the named animation\nsprite.on('animationcomplete-explode', (anim, frame, gameObject, frameKey) => {\n    gameObject.destroy();\n});\n```\n\nAvailable events: `animationstart`, `animationcomplete`, `animationcomplete-{key}`, `animationupdate`, `animationstop`, `animationrepeat`, `animationrestart`. All share the same callback signature: `(animation, frame, gameObject, frameKey)`.\n\n### Frame-Level Callbacks via animationupdate\n\n```js\nsprite.on('animationupdate', (anim, frame, gameObject, frameKey) => {\n    if (anim.key === 'attack' && frame.index === 4) {\n        this.checkHit(gameObject);\n    }\n});\n```\n\n### Per-Frame Duration\n\nIndividual frames can have a `duration` (ms) that is added to the base msPerFrame.\n\n```js\nthis.anims.create({\n    key: 'combo',\n    frames: [\n        { key: 'fighter', frame: 'punch1', duration: 50 },\n        { key: 'fighter', frame: 'kick', duration: 200 },   \u002F\u002F hold longer\n        { key: 'fighter', frame: 'recover', duration: 100 }\n    ],\n    frameRate: 24\n});\n```\n\n### Visibility, Random Start, and TimeScale\n\n```js\n\u002F\u002F Visibility control\nthis.anims.create({\n    key: 'appear', frames: 'sparkle', frameRate: 12,\n    showOnStart: true,      \u002F\u002F sprite.visible = true when anim starts (after delay)\n    hideOnComplete: true,   \u002F\u002F sprite.visible = false when anim completes\n    showBeforeDelay: true   \u002F\u002F show first frame immediately even during delay\n});\n\n\u002F\u002F Random start frame -- each sprite begins on a different frame\nthis.anims.create({\n    key: 'ambient', frames: 'fire', frameRate: 10, repeat: -1,\n    randomFrame: true\n});\n\n\u002F\u002F TimeScale -- per-sprite or global speed control\nsprite.anims.timeScale = 2;                         \u002F\u002F 2x speed\nsprite.play({ key: 'walk', timeScale: 0.5 });       \u002F\u002F half speed via config\nthis.anims.globalTimeScale = 0.5;                    \u002F\u002F affects ALL animations\n```\n\n### Staggered Playback\n\n```js\nconst enemies = this.add.group({ key: 'enemy', repeat: 9 });\nthis.anims.staggerPlay('walk', enemies.getChildren(), 100);\n\u002F\u002F Each sprite starts 100ms after the previous. Pass staggerFirst: false to skip delay on first.\n```\n\n### JSON Export and Import\n\n```js\n\u002F\u002F Export all global animations to JSON\nconst data = this.anims.toJSON();\n\n\u002F\u002F Import animations from JSON (pass true to clear existing animations first)\nthis.anims.fromJSON(data);\nthis.anims.fromJSON(data, true);\n\n\u002F\u002F Check before creating to avoid duplicate warning\nif (!this.anims.exists('walk')) {\n    this.anims.create({ key: 'walk', frames: 'player_walk', frameRate: 12, repeat: -1 });\n}\n```\n\n### Modifying Animation Frames at Runtime\n\n```js\nconst anim = this.anims.get('walk');\n\n\u002F\u002F Add frames to the end\nanim.addFrame(this.anims.generateFrameNumbers('player', { start: 8, end: 10 }));\n\n\u002F\u002F Insert frames at a specific index\nanim.addFrameAt(this.anims.generateFrameNumbers('player', { frames: [5] }), 2);\n\n\u002F\u002F Remove a specific frame object\nconst frame = anim.frames[3];\nanim.removeFrame(frame);\n\n\u002F\u002F Remove frame at index\nanim.removeFrameAt(0);\n```\n\n### Aseprite Support\n\n```js\nthis.load.aseprite('paladin', 'paladin.png', 'paladin.json');\n\u002F\u002F In create:\nthis.anims.createFromAseprite('paladin');               \u002F\u002F all tags\nthis.anims.createFromAseprite('paladin', ['walk']);      \u002F\u002F specific tags only\nsprite.play('walk');                                     \u002F\u002F play by tag name\n```\n\n---\n\n## Configuration Reference\n\n### AnimationConfig (used with `this.anims.create()`)\n\n| Property | Type | Default | Description |\n|---|---|---|---|\n| `key` | string | -- | Unique identifier for the animation |\n| `frames` | string or AnimationFrame[] | `[]` | Texture key string (uses all frames) or array of frame config objects |\n| `sortFrames` | boolean | `true` | Numerically sort frames when using a string key |\n| `defaultTextureKey` | string | `null` | Fallback texture key if not set per-frame |\n| `frameRate` | number | `24` | Playback rate in frames per second (used if `duration` is null) |\n| `duration` | number | `null` | Total animation length in ms (derives frameRate if set) |\n| `skipMissedFrames` | boolean | `true` | Skip frames when lagging behind |\n| `delay` | number | `0` | Delay before playback starts (ms) |\n| `repeat` | number | `0` | Times to repeat after first play (-1 = infinite) |\n| `repeatDelay` | number | `0` | Delay before each repeat (ms) |\n| `yoyo` | boolean | `false` | Reverse back to start before repeating |\n| `showBeforeDelay` | boolean | `false` | Show first frame immediately during delay period |\n| `showOnStart` | boolean | `false` | Set visible=true when animation starts |\n| `hideOnComplete` | boolean | `false` | Set visible=false when animation completes |\n| `randomFrame` | boolean | `false` | Start from a random frame |\n\n### PlayAnimationConfig (used with `sprite.play()`)\n\nAll AnimationConfig timing properties are available, plus:\n\n| Property | Type | Default | Description |\n|---|---|---|---|\n| `key` | string or Animation | -- | Animation key or instance to play |\n| `startFrame` | number | `0` | Frame index to begin playback from |\n| `timeScale` | number | `1` | Speed multiplier for this playback |\n\nValues in PlayAnimationConfig override the animation definition for this specific playback instance.\n\n### Duration vs FrameRate Priority\n\n- If both `duration` and `frameRate` are null: defaults to 24 fps.\n- If only `duration` is set: frameRate is calculated as `totalFrames \u002F (duration \u002F 1000)`.\n- If `frameRate` is set (even if duration is also set): frameRate wins, and duration is derived as `(totalFrames \u002F frameRate) * 1000`.\n\n---\n\n## Events\n\n### Sprite Event Flow\n\n1. `animationstart` -- after delay expires, before first update\n2. `animationupdate` -- each frame change\n3. `animationrepeat` -- each repeat cycle\n4. `animationcomplete` -- natural end (finite repeat)\n5. `animationcomplete-{key}` -- same, with animation key appended\n\nStopped manually: `animationstop` fires instead of complete. Restarted mid-play: `animationrestart` fires.\n\nAll callbacks: `(animation, frame, gameObject, frameKey)`.\n\n### AnimationManager Events\n\nFire on `this.anims`: `addanimation`, `removeanimation`, `pauseall`, `resumeall`.\n\n---\n\n## API Quick Reference\n\n### AnimationManager (`this.anims`)\n\n| Method | Description |\n|---|---|\n| `create(config)` | Create and register a global animation |\n| `remove(key)` | Remove a global animation by key |\n| `get(key)` | Get an Animation instance by key |\n| `exists(key)` | Check if a key is already registered |\n| `generateFrameNumbers(key, config)` | Generate frame array from a spritesheet |\n| `generateFrameNames(key, config)` | Generate frame array from an atlas |\n| `play(key, children)` | Play an animation on an array of Game Objects |\n| `staggerPlay(key, children, stagger)` | Staggered play across multiple Game Objects |\n| `pauseAll()` \u002F `resumeAll()` | Pause\u002Fresume all animations globally |\n| `addMix(animA, animB, delay)` | Set transition delay between two animations |\n| `removeMix(animA, animB?)` | Remove a mix pairing |\n| `getMix(animA, animB)` | Get the mix delay between two animations |\n| `createFromAseprite(key, tags?, target?)` | Create animations from Aseprite JSON |\n| `toJSON()` | Export all animations as JSON data |\n| `fromJSON(data, clear?)` | Load animations from JSON data (pass `true` to clear existing first) |\n\n### AnimationState (`sprite.anims`)\n\n| Method | Description |\n|---|---|\n| `play(key, ignoreIfPlaying?)` | Play an animation |\n| `playReverse(key, ignoreIfPlaying?)` | Play an animation in reverse |\n| `playAfterDelay(key, delay)` | Play after a delay in ms |\n| `playAfterRepeat(key, repeatCount?)` | Play after current anim repeats N times |\n| `chain(key)` | Queue animation(s) to play after current one |\n| `stop()` | Stop immediately |\n| `stopAfterDelay(delay)` | Stop after a delay in ms |\n| `stopAfterRepeat(repeatCount?)` | Stop after N more repeats |\n| `stopOnFrame(frame)` | Stop when a specific frame is reached |\n| `pause(atFrame?)` | Pause playback |\n| `resume(fromFrame?)` | Resume playback |\n| `restart(includeDelay?, resetRepeats?)` | Restart from beginning |\n| `reverse()` | Reverse direction mid-playback |\n| `getName()` | Get the current animation key |\n| `getFrameName()` | Get the current frame key |\n| `getProgress()` | Get progress 0-1 |\n| `setProgress(value)` | Set progress 0-1 |\n| `setRepeat(value)` | Change repeat count during playback |\n| `getTotalFrames()` | Get total frame count |\n| `create(config)` | Create a local animation on this sprite |\n| `exists(key)` | Check if a local animation exists |\n| `get(key)` | Get a local animation by key |\n\nKey properties: `isPlaying`, `hasStarted`, `currentAnim`, `currentFrame`, `forward`, `inReverse`, `timeScale`.\n\n---\n\n## Gotchas\n\n1. **Animations are global by default.** `this.anims.create()` registers across all Scenes. Do not recreate in every Scene -- it logs a warning and returns the existing one.\n2. **`repeat: -1` never fires `animationcomplete`.** Use `stop()` to end infinite animations. Listen for `animationstop` instead.\n3. **`frameRate` beats `duration`.** If both are set, frameRate wins. Set only `duration` (leave frameRate null) to control total length.\n4. **Per-frame `duration` is additive.** Added on top of base msPerFrame, not a replacement.\n5. **`play()` stops the current animation** (fires `animationstop`). Use `play(key, true)` to skip if already playing.\n6. **Mix delays only work with `play()`.** `playAfterDelay`\u002F`playAfterRepeat` bypass mixes.\n7. **Local animations override global.** Same key on a sprite's local map takes priority.\n8. **Sprite shorthand methods.** `sprite.play()`, `sprite.playReverse()`, `sprite.chain()`, `sprite.stop()` wrap `sprite.anims.*`.\n9. **Chained anims fire after stop too.** Clear the queue with `sprite.anims.chain()` before stopping if unwanted.\n10. **`generateFrameNumbers` end=-1 means last frame.** The `__BASE` frame is excluded automatically.\n\n---\n\n## Source File Map\n\n| File | Purpose |\n|---|---|\n| `src\u002Fanimations\u002FAnimationManager.js` | Global singleton -- create, remove, get, generateFrame*, mix, staggerPlay |\n| `src\u002Fanimations\u002FAnimation.js` | Animation definition -- frames, timing, yoyo, repeat logic |\n| `src\u002Fanimations\u002FAnimationState.js` | Per-sprite component -- play, stop, pause, chain, events |\n| `src\u002Fanimations\u002FAnimationFrame.js` | Single frame data -- textureKey, textureFrame, duration, progress |\n| `src\u002Fanimations\u002Fevents\u002Findex.js` | All animation event constants |\n| `src\u002Fanimations\u002Ftypedefs\u002FAnimation.js` | AnimationConfig typedef |\n| `src\u002Fanimations\u002Ftypedefs\u002FPlayAnimationConfig.js` | PlayAnimationConfig typedef |\n| `src\u002Fanimations\u002Ftypedefs\u002FGenerateFrameNumbers.js` | Config for generateFrameNumbers |\n| `src\u002Fanimations\u002Ftypedefs\u002FGenerateFrameNames.js` | Config for generateFrameNames |\n","# Phaser 4 -- Sprite Animations\n\n> AnimationManager (global), AnimationState (per-sprite), creating animations from spritesheets and atlases, playing\u002Fpausing\u002Fchaining, animation events, frame callbacks.\n\n**Related skills:** ..\u002Fsprites-and-images\u002FSKILL.md, ..\u002Floading-assets\u002FSKILL.md\n\n---\n\n## Quick Start\n\n```js\n\u002F\u002F In preload -- load a spritesheet\nthis.load.spritesheet('explosion', 'explosion.png', {\n    frameWidth: 64,\n    frameHeight: 64\n});\n\n\u002F\u002F In create -- define a global animation\nthis.anims.create({\n    key: 'explode',\n    frames: this.anims.generateFrameNumbers('explosion', { start: 0, end: 11 }),\n    frameRate: 24,\n    repeat: 0\n});\n\n\u002F\u002F Play it on a sprite\nconst sprite = this.add.sprite(400, 300, 'explosion');\nsprite.play('explode');\n```\n\n---\n\n## Core Concepts\n\n### AnimationManager vs AnimationState\n\nPhaser has two distinct animation objects:\n\n| Aspect | AnimationManager | AnimationState |\n|---|---|---|\n| Access | `this.anims` (in a Scene) or `this.game.anims` | `sprite.anims` |\n| Scope | Global -- shared across all scenes | Per-sprite instance |\n| Purpose | Create\u002Fstore animation definitions | Control playback on one Game Object |\n| Class | `Phaser.Animations.AnimationManager` | `Phaser.Animations.AnimationState` |\n\nThe 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.\n\nAn `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).\n\n### Local vs Global Animations\n\nWhen `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.\n\n```js\n\u002F\u002F Global animation -- available to all sprites\nthis.anims.create({ key: 'walk', frames: 'player_walk', frameRate: 12, repeat: -1 });\n\n\u002F\u002F Local animation -- only on this sprite\nsprite.anims.create({ key: 'walk', frames: 'npc_walk', frameRate: 10, repeat: -1 });\n\n\u002F\u002F This plays the LOCAL version because local takes priority\nsprite.play('walk');\n```\n\n---\n\n## Common Patterns\n\n### Spritesheet Animation\n\nUse `generateFrameNumbers` for spritesheets (numeric frame indices).\n\n```js\nthis.load.spritesheet('dude', 'dude.png', { frameWidth: 32, frameHeight: 48 });\n\n\u002F\u002F All frames\nthis.anims.create({\n    key: 'run',\n    frames: this.anims.generateFrameNumbers('dude', { start: 0, end: 7 }),\n    frameRate: 10,\n    repeat: -1\n});\n\n\u002F\u002F Custom frame sequence\nthis.anims.create({\n    key: 'idle',\n    frames: this.anims.generateFrameNumbers('dude', { frames: [0, 1, 2, 1] }),\n    frameRate: 6,\n    repeat: -1\n});\n```\n\n`generateFrameNumbers` config:\n- `start` (default `0`) -- first frame index\n- `end` (default `-1`, meaning last frame) -- final frame index\n- `first` -- a single frame to prepend before the range\n- `frames` -- explicit array of frame indices (overrides start\u002Fend)\n\n### Atlas Animation\n\nUse `generateFrameNames` for texture atlases (string-based frame names).\n\n```js\nthis.load.atlas('gems', 'gems.png', 'gems.json');\n\nthis.anims.create({\n    key: 'ruby_sparkle',\n    frames: this.anims.generateFrameNames('gems', {\n        prefix: 'ruby_',\n        start: 1,\n        end: 6,\n        zeroPad: 4   \u002F\u002F produces ruby_0001 through ruby_0006\n    }),\n    frameRate: 12,\n    repeat: -1\n});\n```\n\n`generateFrameNames` config:\n- `prefix` -- prepended to each frame number\n- `suffix` -- appended after each frame number\n- `start`, `end` -- numeric range\n- `zeroPad` -- left-pad numbers to this length with zeros\n- `frames` -- explicit array of frame numbers (overrides start\u002Fend)\n\nIf you call `generateFrameNames(key)` with no config, it returns all frames from the atlas.\n\n### String as Frames\n\nPass a texture key string as `frames` to use all frames from that texture, sorted numerically by default. Set `sortFrames: false` to disable sorting.\n\n```js\nthis.anims.create({ key: 'walk', frames: 'player_walk', frameRate: 12, repeat: -1 });\n```\n\n### Yoyo and Repeat\n\n```js\nthis.anims.create({\n    key: 'pulse',\n    frames: this.anims.generateFrameNumbers('orb', { start: 0, end: 5 }),\n    frameRate: 10,\n    yoyo: true,       \u002F\u002F plays forward then backward\n    repeat: -1,       \u002F\u002F -1 = forever\n    repeatDelay: 500   \u002F\u002F ms pause between each repeat cycle\n});\n```\n\nWhen `yoyo` is true, the animation plays forward then reverses. The full cycle counts as one play.\n\n### Chaining Animations\n\n```js\nsprite.play('attack');\nsprite.chain('idle');                        \u002F\u002F play idle after attack completes\nsprite.chain(['fall', 'land', 'idle']);       \u002F\u002F chain multiple\nsprite.anims.chain();                        \u002F\u002F clear the chain queue\n```\n\nChaining is per-sprite. Chained animations start after `animationcomplete` or `animationstop`. An animation with `repeat: -1` never completes -- call `stop()` to trigger the chain.\n\n### Playing in Reverse\n\n```js\n\u002F\u002F Play an animation from last frame to first\nsprite.playReverse('walk');\n\n\u002F\u002F Reverse direction mid-playback\nsprite.anims.reverse();\n```\n\n`playReverse` sets `forward = false` and `inReverse = true`. The `reverse()` method toggles direction mid-playback.\n\n### Play Variants\n\n```js\nsprite.play('walk', true);                   \u002F\u002F ignoreIfPlaying = true\nsprite.anims.playAfterDelay('walk', 1000);   \u002F\u002F play after 1s delay\nsprite.anims.playAfterRepeat('walk', 2);     \u002F\u002F play after current anim repeats 2x\n```\n\n### Animation Mixing\n\nAdds a transition delay between two specific animations, set globally on the AnimationManager.\n\n```js\nthis.anims.addMix('idle', 'walk', 200);\nthis.anims.addMix('walk', 'idle', 300);\n\nsprite.play('idle');\nsprite.play('walk');   \u002F\u002F 200ms mix delay applied automatically\n\nthis.anims.removeMix('idle', 'walk');   \u002F\u002F remove specific pair\nthis.anims.removeMix('idle');           \u002F\u002F remove all mixes for 'idle'\n```\n\nMix delays only apply with `sprite.play()`, not `playAfterDelay` or `playAfterRepeat`.\n\n### Pause, Resume, and Stop\n\n```js\nsprite.anims.pause();                 \u002F\u002F pause per-sprite\nsprite.anims.resume();                \u002F\u002F resume per-sprite\nthis.anims.pauseAll();                \u002F\u002F global pause\nthis.anims.resumeAll();               \u002F\u002F global resume\n\nsprite.anims.stop();                  \u002F\u002F stop immediately\nsprite.anims.stopAfterDelay(2000);    \u002F\u002F stop after 2 seconds\nsprite.anims.stopAfterRepeat(1);      \u002F\u002F stop after 1 more repeat\nsprite.anims.stopOnFrame(frame);      \u002F\u002F stop when a specific frame is reached\n```\n\nAll stop methods fire `animationstop` (not `animationcomplete`). Chained animations trigger after stop.\n\n### Animation Events\n\n```js\nsprite.on('animationcomplete', (anim, frame, gameObject, frameKey) => {\n    console.log('completed:', anim.key);\n});\n\n\u002F\u002F Key-specific complete -- only fires for the named animation\nsprite.on('animationcomplete-explode', (anim, frame, gameObject, frameKey) => {\n    gameObject.destroy();\n});\n```\n\nAvailable events: `animationstart`, `animationcomplete`, `animationcomplete-{key}`, `animationupdate`, `animationstop`, `animationrepeat`, `animationrestart`. All share the same callback signature: `(animation, frame, gameObject, frameKey)`.\n\n### Frame-Level Callbacks via animationupdate\n\n```js\nsprite.on('animationupdate', (anim, frame, gameObject, frameKey) => {\n    if (anim.key === 'attack' && frame.index === 4) {\n        this.checkHit(gameObject);\n    }\n});\n```\n\n### Per-Frame Duration\n\nIndividual frames can have a `duration` (ms) that is added to the base msPerFrame.\n\n```js\nthis.anims.create({\n    key: 'combo',\n    frames: [\n        { key: 'fighter', frame: 'punch1', duration: 50 },\n        { key: 'fighter', frame: 'kick', duration: 200 },   \u002F\u002F hold longer\n        { key: 'fighter', frame: 'recover', duration: 100 }\n    ],\n    frameRate: 24\n});\n```\n\n### Visibility, Random Start, and TimeScale\n\n```js\n\u002F\u002F Visibility control\nthis.anims.create({\n    key: 'appear', frames: 'sparkle', frameRate: 12,\n    showOnStart: true,      \u002F\u002F sprite.visible = true when anim starts (after delay)\n    hideOnComplete: true,   \u002F\u002F sprite.visible = false when anim completes\n    showBeforeDelay: true   \u002F\u002F show first frame immediately even during delay\n});\n\n\u002F\u002F Random start frame -- each sprite begins on a different frame\nthis.anims.create({\n    key: 'ambient', frames: 'fire', frameRate: 10, repeat: -1,\n    randomFrame: true\n});\n\n\u002F\u002F TimeScale -- per-sprite or global speed control\nsprite.anims.timeScale = 2;                         \u002F\u002F 2x speed\nsprite.play({ key: 'walk', timeScale: 0.5 });       \u002F\u002F half speed via config\nthis.anims.globalTimeScale = 0.5;                    \u002F\u002F affects ALL animations\n```\n\n### Staggered Playback\n\n```js\nconst enemies = this.add.group({ key: 'enemy', repeat: 9 });\nthis.anims.staggerPlay('walk', enemies.getChildren(), 100);\n\u002F\u002F Each sprite starts 100ms after the previous. Pass staggerFirst: false to skip delay on first.\n```\n\n### JSON Export and Import\n\n```js\n\u002F\u002F Export all global animations to JSON\nconst data = this.anims.toJSON();\n\n\u002F\u002F Import animations from JSON (pass true to clear existing animations first)\nthis.anims.fromJSON(data);\nthis.anims.fromJSON(data, true);\n\n\u002F\u002F Check before creating to avoid duplicate warning\nif (!this.anims.exists('walk')) {\n    this.anims.create({ key: 'walk', frames: 'player_walk', frameRate: 12, repeat: -1 });\n}\n```\n\n### Modifying Animation Frames at Runtime\n\n```js\nconst anim = this.anims.get('walk');\n\n\u002F\u002F Add frames to the end\nanim.addFrame(this.anims.generateFrameNumbers('player', { start: 8, end: 10 }));\n\n\u002F\u002F Insert frames at a specific index\nanim.addFrameAt(this.anims.generateFrameNumbers('player', { frames: [5] }), 2);\n\n\u002F\u002F Remove a specific frame object\nconst frame = anim.frames[3];\nanim.removeFrame(frame);\n\n\u002F\u002F Remove frame at index\nanim.removeFrameAt(0);\n```\n\n### Aseprite Support\n\n```js\nthis.load.aseprite('paladin', 'paladin.png', 'paladin.json');\n\u002F\u002F In create:\nthis.anims.createFromAseprite('paladin');               \u002F\u002F all tags\nthis.anims.createFromAseprite('paladin', ['walk']);      \u002F\u002F specific tags only\nsprite.play('walk');                                     \u002F\u002F play by tag name\n```\n\n---\n\n## Configuration Reference\n\n### AnimationConfig (used with `this.anims.create()`)\n\n| Property | Type | Default | Description |\n|---|---|---|---|\n| `key` | string | -- | Unique identifier for the animation |\n| `frames` | string or AnimationFrame[] | `[]` | Texture key string (uses all frames) or array of frame config objects |\n| `sortFrames` | boolean | `true` | Numerically sort frames when using a string key |\n| `defaultTextureKey` | string | `null` | Fallback texture key if not set per-frame |\n| `frameRate` | number | `24` | Playback rate in frames per second (used if `duration` is null) |\n| `duration` | number | `null` | Total animation length in ms (derives frameRate if set) |\n| `skipMissedFrames` | boolean | `true` | Skip frames when lagging behind |\n| `delay` | number | `0` | Delay before playback starts (ms) |\n| `repeat` | number | `0` | Times to repeat after first play (-1 = infinite) |\n| `repeatDelay` | number | `0` | Delay before each repeat (ms) |\n| `yoyo` | boolean | `false` | Reverse back to start before repeating |\n| `showBeforeDelay` | boolean | `false` | Show first frame immediately during delay period |\n| `showOnStart` | boolean | `false` | Set visible=true when animation starts |\n| `hideOnComplete` | boolean | `false` | Set visible=false when animation completes |\n| `randomFrame` | boolean | `false` | Start from a random frame |\n\n### PlayAnimationConfig (used with `sprite.play()`)\n\nAll AnimationConfig timing properties are available, plus:\n\n| Property | Type | Default | Description |\n|---|---|---|---|\n| `key` | string or Animation | -- | Animation key or instance to play |\n| `startFrame` | number | `0` | Frame index to begin playback from |\n| `timeScale` | number | `1` | Speed multiplier for this playback |\n\nValues in PlayAnimationConfig override the animation definition for this specific playback instance.\n\n### Duration vs FrameRate Priority\n\n- If both `duration` and `frameRate` are null: defaults to 24 fps.\n- If only `duration` is set: frameRate is calculated as `totalFrames \u002F (duration \u002F 1000)`.\n- If `frameRate` is set (even if duration is also set): frameRate wins, and duration is derived as `(totalFrames \u002F frameRate) * 1000`.\n\n---\n\n## Events\n\n### Sprite Event Flow\n\n1. `animationstart` -- after delay expires, before first update\n2. `animationupdate` -- each frame change\n3. `animationrepeat` -- each repeat cycle\n4. `animationcomplete` -- natural end (finite repeat)\n5. `animationcomplete-{key}` -- same, with animation key appended\n\nStopped manually: `animationstop` fires instead of complete. Restarted mid-play: `animationrestart` fires.\n\nAll callbacks: `(animation, frame, gameObject, frameKey)`.\n\n### AnimationManager Events\n\nFire on `this.anims`: `addanimation`, `removeanimation`, `pauseall`, `resumeall`.\n\n---\n\n## API Quick Reference\n\n### AnimationManager (`this.anims`)\n\n| Method | Description |\n|---|---|\n| `create(config)` | Create and register a global animation |\n| `remove(key)` | Remove a global animation by key |\n| `get(key)` | Get an Animation instance by key |\n| `exists(key)` | Check if a key is already registered |\n| `generateFrameNumbers(key, config)` | Generate frame array from a spritesheet |\n| `generateFrameNames(key, config)` | Generate frame array from an atlas |\n| `play(key, children)` | Play an animation on an array of Game Objects |\n| `staggerPlay(key, children, stagger)` | Staggered play across multiple Game Objects |\n| `pauseAll()` \u002F `resumeAll()` | Pause\u002Fresume all animations globally |\n| `addMix(animA, animB, delay)` | Set transition delay between two animations |\n| `removeMix(animA, animB?)` | Remove a mix pairing |\n| `getMix(animA, animB)` | Get the mix delay between two animations |\n| `createFromAseprite(key, tags?, target?)` | Create animations from Aseprite JSON |\n| `toJSON()` | Export all animations as JSON data |\n| `fromJSON(data, clear?)` | Load animations from JSON data (pass `true` to clear existing first) |\n\n### AnimationState (`sprite.anims`)\n\n| Method | Description |\n|---|---|\n| `play(key, ignoreIfPlaying?)` | Play an animation |\n| `playReverse(key, ignoreIfPlaying?)` | Play an animation in reverse |\n| `playAfterDelay(key, delay)` | Play after a delay in ms |\n| `playAfterRepeat(key, repeatCount?)` | Play after current anim repeats N times |\n| `chain(key)` | Queue animation(s) to play after current one |\n| `stop()` | Stop immediately |\n| `stopAfterDelay(delay)` | Stop after a delay in ms |\n| `stopAfterRepeat(repeatCount?)` | Stop after N more repeats |\n| `stopOnFrame(frame)` | Stop when a specific frame is reached |\n| `pause(atFrame?)` | Pause playback |\n| `resume(fromFrame?)` | Resume playback |\n| `restart(includeDelay?, resetRepeats?)` | Restart from beginning |\n| `reverse()` | Reverse direction mid-playback |\n| `getName()` | Get the current animation key |\n| `getFrameName()` | Get the current frame key |\n| `getProgress()` | Get progress 0-1 |\n| `setProgress(value)` | Set progress 0-1 |\n| `setRepeat(value)` | Change repeat count during playback |\n| `getTotalFrames()` | Get total frame count |\n| `create(config)` | Create a local animation on this sprite |\n| `exists(key)` | Check if a local animation exists |\n| `get(key)` | Get a local animation by key |\n\nKey properties: `isPlaying`, `hasStarted`, `currentAnim`, `currentFrame`, `forward`, `inReverse`, `timeScale`.\n\n---\n\n## Gotchas\n\n1. **Animations are global by default.** `this.anims.create()` registers across all Scenes. Do not recreate in every Scene -- it logs a warning and returns the existing one.\n2. **`repeat: -1` never fires `animationcomplete`.** Use `stop()` to end infinite animations. Listen for `animationstop` instead.\n3. **`frameRate` beats `duration`.** If both are set, frameRate wins. Set only `duration` (leave frameRate null) to control total length.\n4. **Per-frame `duration` is additive.** Added on top of base msPerFrame, not a replacement.\n5. **`play()` stops the current animation** (fires `animationstop`). Use `play(key, true)` to skip if already playing.\n6. **Mix delays only work with `play()`.** `playAfterDelay`\u002F`playAfterRepeat` bypass mixes.\n7. **Local animations override global.** Same key on a sprite's local map takes priority.\n8. **Sprite shorthand methods.** `sprite.play()`, `sprite.playReverse()`, `sprite.chain()`, `sprite.stop()` wrap `sprite.anims.*`.\n9. **Chained anims fire after stop too.** Clear the queue with `sprite.anims.chain()` before stopping if unwanted.\n10. **`generateFrameNumbers` end=-1 means last frame.** The `__BASE` frame is excluded automatically.\n\n---\n\n## Source File Map\n\n| File | Purpose |\n|---|---|\n| `src\u002Fanimations\u002FAnimationManager.js` | Global singleton -- create, remove, get, generateFrame*, mix, staggerPlay |\n| `src\u002Fanimations\u002FAnimation.js` | Animation definition -- frames, timing, yoyo, repeat logic |\n| `src\u002Fanimations\u002FAnimationState.js` | Per-sprite component -- play, stop, pause, chain, events |\n| `src\u002Fanimations\u002FAnimationFrame.js` | Single frame data -- textureKey, textureFrame, duration, progress |\n| `src\u002Fanimations\u002Fevents\u002Findex.js` | All animation event constants |\n| `src\u002Fanimations\u002Ftypedefs\u002FAnimation.js` | AnimationConfig typedef |\n| `src\u002Fanimations\u002Ftypedefs\u002FPlayAnimationConfig.js` | PlayAnimationConfig typedef |\n| `src\u002Fanimations\u002Ftypedefs\u002FGenerateFrameNumbers.js` | Config for generateFrameNumbers |\n| `src\u002Fanimations\u002Ftypedefs\u002FGenerateFrameNames.js` | Config for generateFrameNames |\n",{"name":5,"description":7},"master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fskills_sh\u002Fs\u002Fskills-sh_phaserjs_phaser_animations",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill animations",{"tool":39,"command":40},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill animations",{"tool":42,"command":43},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill animations","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fskills_sh\u002Fs\u002Fskills-sh_phaserjs_phaser_animations\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]