Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "sprite-animation-pack",
"version": "0.1.0",
"description": "Turn a character's animation frames — a folder of PNGs or a whole sprite sheet — into a game-ready animation pack: actions grouped automatically, every frame lined up on the feet (or kept in place), frame timing and loops, a uniform-cell atlas PNG, Aseprite/Phaser JSON, a Godot 4 SpriteFrames .tres and Unity slicing notes. Preview each action with onion skin and nudge frames pixel by pixel. Runs locally; no API keys.",
"description_i18n": {
"en": "Turn a character's animation frames — a folder of PNGs or a whole sprite sheet — into a game-ready animation pack: actions grouped automatically, every frame lined up on the feet (or kept in place), frame timing and loops, a uniform-cell atlas PNG, Aseprite/Phaser JSON, a Godot 4 SpriteFrames .tres and Unity slicing notes. Preview each action with onion skin and nudge frames pixel by pixel. Runs locally; no API keys.",
"zh-CN": "把角色的动作帧(一文件夹 PNG 或一整张精灵图)整理成游戏可直接用的动作包:自动按动作分组,所有帧按脚底对齐(或保持原位),设置帧时长和循环,导出等格图集 PNG、Aseprite/Phaser JSON、Godot 4 SpriteFrames .tres 和 Unity 切片说明。面板里逐个动作播放预览,带洋葱皮,可逐像素微调。在本地运行,无需 API 密钥。"
},
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"keywords": [
"sprite",
"sprite sheet",
"animation",
"atlas",
"pixel art",
"godot",
"phaser",
"unity",
"aseprite",
"game",
"精灵图",
"动作",
"图集",
"游戏"
],
"skills": "skills",
"mcpServers": {
"sprite-animation-pack": {
"type": "stdio",
"command": "node",
"args": [
"${ZCODE_PLUGIN_ROOT}/dist/server.mjs"
],
"cwd": "${ZCODE_PROJECT_DIR}",
"timeoutMs": 900000,
"env": {
"ZCODE_WORKSPACE_ROOT": "${ZCODE_PROJECT_DIR}"
}
}
},
"ui": {
"surfaces": [
{
"id": "editor",
"title": {
"zh-CN": "游戏角色动作包",
"en-US": "Sprite Animation Pack"
},
"icon": "gamepad-2",
"server": "sprite-animation-pack",
"resourceUri": "ui://sprite-animation-pack/panel.html",
"availability": "session"
}
]
}
}
21 changes: 21 additions & 0 deletions external_plugins/sprite-animation-pack/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Penova

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
66 changes: 66 additions & 0 deletions external_plugins/sprite-animation-pack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Sprite Animation Pack

Turn a character's animation frames into a pack your game engine can load: one atlas, every action's frames lined up on the same anchor, frame timing, loops, and import files for Phaser, Godot and Unity.

## Features

- **Input**:
- A folder of PNG frames. Actions are grouped by sub-folder (`run/1.png`) or by file name without the frame number (`hero_run_01.png` → `run`), and frames are sorted naturally.
- Or a whole sprite sheet sliced by a grid (cell size or cols/rows), with one action per row or per column. Empty cells are skipped.
- A solid background (magenta, green, or the corner colour) can be keyed out.
- **Alignment**: every frame is placed in a uniform cell so that its anchor sits at the same point.
- **feet**: horizontal centre of mass, resting on the lowest pixel. This is the default for trimmed frames.
- **keep**: the original position, chosen automatically when frames share a padded canvas, which preserves jumps.
- **center** is also available.
- Each frame can be nudged by 1 px.
- **Panel**:
- Action list with name, fps, loop and alignment.
- Live preview with zoom, ground line and onion skin, plus play/pause/step.
- Frame strip with duration per frame, nudge, reorder and delete.
- Settings and the atlas preview.
- **Export** to `sprites/<name>/`:
- `<name>.png`: atlas with uniform cells and one row per action, with an integer nearest-neighbour scale (1–8×) for pixel art.
- `<name>.json`: Aseprite format with frame durations and tags. Phaser 3 loads it with `load.aseprite` + `anims.createFromAseprite`; plain atlas loaders read it too.
- `<name>.tres`: Godot 4 `SpriteFrames`, with per-action speed, loop and relative frame durations. It references the atlas next to it.
- `<name>.unity.md`: Sprite Editor grid slicing settings, the pivot, and every frame's rectangle.
- `<name>.phaser.js`: a ready-to-paste snippet.
- `<name>.sprites.json`: the project, to reopen and change.

## Usage

Ask the agent in ZCode Desktop:

- "Slice hero.png into 32×32 cells — rows are idle, run and jump — and export a pack for Godot and Phaser"
- "Line up the frames in art/knight/ on the feet, make attack play once at 15 fps"
- "Export the runner at 4× for pixel-art scaling"

## Tools

| Tool | Purpose |
|---|---|
| `sprite_open` | Open a frames folder/list, a sprite sheet (+ grid) or a project; group, align and open the panel |
| `sprite_save` | Save names, order, timing, loops, alignment, nudges and settings |
| `sprite_export` | Write the atlas, Aseprite/Phaser JSON, Godot .tres, Unity notes and the project |

## Scope (v0.1)

- PNG frames only (with transparency, or a solid background to key out).
- Uniform cells; no tight packing or rotation.
- Generating new frames ("fill in the missing attack frames") is not included. Generate them with an image tool first, then add them to the folder.
- Unity gets slicing instructions rather than a `.meta` file, because Unity assigns its own GUIDs.

## Privacy, network and files

- **Everything runs locally.** No network, no uploads, no API keys or accounts.
- Reads only the images you pick. Writes only to `sprites/<name>/` in the workspace. No hooks.

## Build and test (developers)

- Source: `ui-plugins/sprite-animation-pack/`.
- Build: `pnpm install --frozen-lockfile && pnpm build`, then add `dist/local-marketplace` as a local source.
- Tests: `pnpm --filter @penova/plugin-sprite-animation-pack test` and `test:e2e`.
- `E2E_SPRITES` can point to real art. We used the CC0 "Runner character" by Blue Yeti Studios from OpenGameArt, both as the sheet and as trimmed frames.

## Third-party components and licenses

MIT licensed (author: Penova). Bundled: pngjs (MIT), jpeg-js (BSD-3-Clause), MCP SDK and ext-apps (MIT), zod (MIT); the full list is in `dist/THIRD_PARTY_NOTICES.txt`.
66 changes: 66 additions & 0 deletions external_plugins/sprite-animation-pack/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 游戏角色动作包

把角色的动作帧整理成游戏引擎能直接加载的动作包:一张图集,每个动作的帧都对齐到同一个锚点,带帧时长、循环设置,以及 Phaser、Godot、Unity 的导入文件。

## 功能

- **输入**:
- 一文件夹 PNG 帧:按子文件夹(`run/1.png`)或去掉帧号后的文件名(`hero_run_01.png` → `run`)分成动作,帧按自然顺序排列。
- 或一整张精灵图:按网格切开(格子尺寸或行列数),每行或每列一个动作,空格子自动跳过。
- 纯色底(品红、绿幕或左上角颜色)可以去掉。
- **对齐**:所有帧放进统一大小的格子,锚点落在同一位置。
- **脚底**:取不透明像素的水平重心,贴着最低点。裁切过的帧默认用这种方式。
- **保持原位**:帧共用一块留有透明边的画布时自动选用,跳跃的高度会保留。
- 也可以选**中心**对齐。
- 每帧都能逐像素微调。
- **面板**:
- 动作列表:名字、fps、循环、对齐方式。
- 实时预览:可放大,带地面线和洋葱皮,可播放 / 暂停 / 逐帧。
- 帧条:可改每帧时长、微调位置、调整顺序、删除。
- 参数设置和图集预览。
- **导出**(到 `sprites/<名字>/`):
- `名字.png`:等格图集,每个动作一行;像素画可按整数倍(1–8×)最近邻放大,不会糊。
- `名字.json`:Aseprite 格式,带每帧时长和动作标签。Phaser 3 用 `load.aseprite` + `anims.createFromAseprite` 加载,普通 atlas 加载方式也能读。
- `名字.tres`:Godot 4 的 `SpriteFrames`,每个动作有速度、循环和各帧相对时长,引用同一文件夹里的图集。
- `名字.unity.md`:Unity Sprite Editor 按网格切片的参数、Pivot,以及每帧的矩形。
- `名字.phaser.js`:可以直接粘贴的代码片段。
- `名字.sprites.json`:工程文件,可以重新打开修改。

## 使用

在 ZCode Desktop 中对 Agent 说:

- “把 hero.png 按 32×32 切开,三行分别是 idle、run、jump,导出 Godot 和 Phaser 用的动作包”
- “把 art/knight/ 里的帧按脚底对齐,attack 只播一次、15 帧每秒”
- “把 runner 放大 4 倍导出,像素风不要糊”

## 工具

| 工具 | 作用 |
|---|---|
| `sprite_open` | 打开帧文件夹 / 文件列表、精灵图(加网格)或工程;分组、对齐并打开面板 |
| `sprite_save` | 保存名字、顺序、时长、循环、对齐方式、微调和参数 |
| `sprite_export` | 导出图集、Aseprite/Phaser JSON、Godot .tres、Unity 说明和工程 |

## 范围(v0.1)

- 只支持 PNG 帧(透明底,或可以去掉的纯色底)。
- 等格排列,不做紧密打包或旋转。
- 不包含“补全动作”(生成新帧):先用生图工具生成新帧,再放进文件夹。
- Unity 提供切片说明而不是 `.meta` 文件,因为 GUID 由 Unity 自己分配。

## 隐私、网络与文件

- **全部在本地运行**:不联网、不上传,不需要 API 密钥或账号。
- 只读取你选的图片,只写入工作区的 `sprites/<名字>/`。没有 hooks。

## 构建与测试(开发者)

- 源码位于 `ui-plugins/sprite-animation-pack/`。
- 构建:`pnpm install --frozen-lockfile && pnpm build`,然后把 `dist/local-marketplace` 添加为本地来源。
- 测试:`pnpm --filter @penova/plugin-sprite-animation-pack test` 和 `test:e2e`。
- `E2E_SPRITES` 可以指向真实素材。我们用的是 OpenGameArt 上 Blue Yeti Studios 的 CC0 素材“Runner character”,精灵图和裁切后的单帧两种形式都测了。

## 第三方组件与许可

MIT 许可(作者:Penova)。打包的组件:pngjs(MIT)、jpeg-js(BSD-3-Clause)、MCP SDK 和 ext-apps(MIT)、zod(MIT);完整清单见 `dist/THIRD_PARTY_NOTICES.txt`。
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: sprite-animation-pack
description: 把角色动作帧(PNG 文件夹或整张精灵图)整理成游戏动作包:按动作分组、脚底对齐、帧时长与循环,导出图集 PNG、Aseprite/Phaser JSON、Godot .tres、Unity 切片说明。用户提到“精灵图 / 动作帧 / 序列帧 / 图集 / Godot SpriteFrames / Phaser 动画”时使用。
---

# 游戏角色动作包

1. 打开素材:
- 帧文件夹:`sprite_open(frames: "art/hero", fps?)`。
- 整张图:`sprite_open(sheet: "hero.png", grid: {width, height} 或 {cols, rows}, by: "row"|"column", actions: ["idle","run",…])`。
- 不知道格子尺寸时先问用户,或者根据报错里给出的图片尺寸推断(常见 16/24/32/48/64)。
2. 读返回的摘要:每个动作的帧数和对齐方式(auto → feet 或 keep)。跳跃、攻击这类带位移的动作如果是裁切过的单帧,建议用户在面板里检查,必要时改为 keep 或微调。
3. 按用户要求改工程,然后 `sprite_save(project)`:
- 动作名:小写英文最适合引擎。
- `frames[].duration`(毫秒)、`loop`、`anchor`、`scale`(像素画用 2–4×)。
- 拆分或合并动作:直接编辑 `actions[].frames`。
4. `sprite_export(project)`,告诉用户输出文件夹里各文件的用途:
- Phaser:`load.aseprite` + `createFromAseprite`。
- Godot:把 `.tres` 和 PNG 放进同一文件夹,在 AnimatedSprite2D 上用这个 `.tres`。
- Unity:照 `.unity.md` 的说明切片。
52 changes: 52 additions & 0 deletions marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,58 @@
"把上一个 Hi3D 任务生成的模型按角色拆分成部件"
]
}
},
{
"name": "sprite-animation-pack",
"componentTypes": [
"ui"
],
"source": "./external_plugins/sprite-animation-pack",
"displayName": "Sprite Animation Pack",
"displayName_i18n": {
"en": "Sprite Animation Pack",
"zh-CN": "游戏角色动作包"
},
"description": "Turn a character's animation frames — a folder of PNGs or a whole sprite sheet — into a game-ready animation pack: actions grouped automatically, every frame lined up on the feet (or kept in place), frame timing and loops, a uniform-cell atlas PNG, Aseprite/Phaser JSON, a Godot 4 SpriteFrames .tres and Unity slicing notes. Preview each action with onion skin and nudge frames pixel by pixel. Runs locally; no API keys.",
"description_i18n": {
"en": "Turn a character's animation frames — a folder of PNGs or a whole sprite sheet — into a game-ready animation pack: actions grouped automatically, every frame lined up on the feet (or kept in place), frame timing and loops, a uniform-cell atlas PNG, Aseprite/Phaser JSON, a Godot 4 SpriteFrames .tres and Unity slicing notes. Preview each action with onion skin and nudge frames pixel by pixel. Runs locally; no API keys.",
"zh-CN": "把角色的动作帧(一文件夹 PNG 或一整张精灵图)整理成游戏可直接用的动作包:自动按动作分组,所有帧按脚底对齐(或保持原位),设置帧时长和循环,导出等格图集 PNG、Aseprite/Phaser JSON、Godot 4 SpriteFrames .tres 和 Unity 切片说明。面板里逐个动作播放预览,带洋葱皮,可逐像素微调。在本地运行,无需 API 密钥。"
},
"version": "0.1.0",
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"category": "productivity",
"keywords": [
"sprite",
"sprite sheet",
"animation",
"atlas",
"pixel art",
"godot",
"phaser",
"unity",
"aseprite",
"game",
"精灵图",
"动作",
"图集",
"游戏"
],
"examplePrompts": [
"Slice hero.png into 32×32 cells — rows are idle, run and jump — and export a pack for Godot and Phaser",
"Line up the frames in art/knight/ on the feet, make attack play once at 15 fps",
"Export the runner at 4× for pixel-art scaling"
],
"examplePrompts_i18n": {
"zh-CN": [
"把 hero.png 按 32×32 切开,三行分别是 idle、run、jump,导出 Godot 和 Phaser 用的动作包",
"把 art/knight/ 里的帧按脚底对齐,attack 只播一次、15 帧每秒",
"把 runner 放大 4 倍导出,像素风不要糊"
]
}
}
]
}
Loading