Skip to content

feat(ui-plugins): add Sprite Animation Pack (sprite-animation-pack) - #232

Open
ppppp2005-p wants to merge 12 commits into
zai-org:mainfrom
ppppp2005-p:feat/sprite-animation-pack
Open

ppppp2005-p wants to merge 12 commits into
zai-org:mainfrom
ppppp2005-p:feat/sprite-animation-pack

Conversation

@ppppp2005-p

Copy link
Copy Markdown

Plugin type (required) / 插件类型(必填)

  • UI Plugin / 是 UI 插件 — provides MCP Apps interactive pages / 提供 MCP Apps 交互页面
  • Standard plugin / 普通插件(非 UI)
  • Not applicable / 不适用

Affected plugin name(s) / 涉及的插件名称:sprite-animation-pack (UI Plugin, new)

What / 改动内容

New community UI plugin Sprite Animation Pack / 游戏角色动作包: character frames (PNG folder or sprite sheet) → aligned, timed animation pack for Phaser, Godot and Unity.

  • Tools:
    • sprite_open:
      • Frames folder/list, grouped by sub-folder or by name minus frame number (natural sort, common prefix stripped).
      • Or a sheet sliced by cell size or cols/rows, one action per row or column; empty cells skipped; solid background keyed out (auto corner / magenta / green).
      • Or a .sprites.json project.
    • sprite_save.
    • sprite_export: atlas PNG, Aseprite-format JSON with frameTags and durations, Godot 4 SpriteFrames .tres, Unity grid-slicing notes with the pivot and rects, Phaser snippet, project.
    • App-only: atlas_preview, workspace_files.
  • Alignment:
    • Uniform cells, symmetric around the anchor.
    • feet: horizontal centre of mass, lowest pixel. keep: original canvas position, picked automatically for same-size padded canvases so jumps are kept. center.
    • Per-frame 1 px nudges.
  • Atlas: integer nearest-neighbour scale (1–8×), one row per action, wraps at 4096 px.
  • Panel:
    • Actions with fps, loop and alignment.
    • Canvas preview with zoom, ground/anchor line and onion skin; play/step.
    • Frame strip with durations, nudges, reorder and delete.
    • Settings and the atlas preview.

Network / API / side effects: local stdio MCP server; no network, no API keys, no hooks. Writes only sprites/<name>/ in the workspace.

Third-party: pngjs (MIT), jpeg-js (BSD-3-Clause), MCP SDK / ext-apps (MIT), zod (MIT).

Tests:

  • vitest over MCP with generated characters, covering:
    • Grouping and normalisation.
    • Trimmed frames aligned to one ground line, checked pixel-wise in the exported 2× atlas.
    • Contents of the JSON tags/rects/durations, the .tres regions/speed/loop and the Unity notes.
    • Sheet slicing with magenta keying; keep preserving a 4 px jump vs feet flattening it.
    • Nudges and errors.
  • Chrome e2e with the official AppBridge host on CC0 OpenGameArt "Runner character" art, both as trimmed frames and as the original 32×32 sheet:
    • Agent opens; user selects run, steps to a frame, nudges it, turns on onion skin, sets jump to play once and scale 4×; then exports.
    • Tags, project nudge and .tres checked; agent then opens the sheet with a grid.
  • validate.py, build_dist.py, git diff --check, oxlint and tsc pass.

A ZCode Desktop demo recording is attached in the comments. / ZCode 桌面版演示录屏见评论。

Self-check / 自查清单

  • Plugin name is unique kebab-case; new external plugin directory is external_plugins/<name>/
  • Usage category is set (productivity)
  • Plugin type and affected names are declared above
  • version 0.1.0 in both plugin.json and marketplace.json
  • README.md (EN) and README_CN.md (中文) both provided and equivalent
  • description_i18n has both en and zh-CN
  • No secrets, machine-specific paths, or private dependencies
  • Model/API/network dependencies documented
  • python3 scripts/validate.py and python3 scripts/build_dist.py pass locally
  • Exercised in ZCode Desktop (ZCode 4.0.0, macOS arm64: installed from a local marketplace, sprite_open (sprites/runner-frames, 17 frames) → panel → idle/run loop, jump once, 3x nearest-neighbour → sprite_save runner.sprites.json → sprite_export: runner.png atlas + runner.json (Aseprite tags) + Godot .tres + Unity notes + Phaser snippet; demo video in the comments)

@ppppp2005-p

Copy link
Copy Markdown
Author

ZCode desktop demo (ZCode 4.0.0, macOS arm64)

sprite-animation-pack-demo.mp4

Flow shown:

  1. Installed sprite-animation-pack from a local marketplace built from this PR's branch.
  2. Asked ZCode to open the sprites/runner-frames frame folder, scale the pixel art 3×, loop idle, play jump once, then save and export. The agent called sprite_open, which opened the side panel (animations grouped from file names, fps / loop / alignment per animation, live preview).
  3. The agent kept jump at "keep original position" (its 4 frames already share one baseline, so feet-alignment would only add 1-px jitter), saved the project with sprite_save (sprites/runner/runner.sprites.json), and sprite_export wrote:
    • runner.png: 17-frame atlas, nearest-neighbour 3×
    • runner.json: Aseprite-style frames + frameTags (idle 0–4, jump 5–8 once, run 9–16)
    • runner.tres (Godot SpriteFrames), runner.unity.md (Unity import notes), runner.phaser.js (Phaser animation snippet)
  4. The last card shows the exported atlas.

演示流程:本地 marketplace 安装 → sprite_open 打开面板 → 设置循环/对齐/3 倍像素放大 → sprite_save → sprite_export 导出图集 + JSON + Godot/Unity/Phaser 文件。

@panda920

Copy link
Copy Markdown
Collaborator

✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically.

@panda920

Copy link
Copy Markdown
Collaborator

✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants