MoonBit-native pixel animation asset parser, validator, runtime model, and export toolkit.
moon add WangYF0829/moonpixelanimkitmoon check
moon test
moon run examples/basic
moon run cmd/main
moon run cmd/main -- --json
moon run cmd/main -- --aselet parsed = @moonpixelanimkit.parse_sprite_sheet_json(json_text)
if parsed.ok {
let library = @moonpixelanimkit.build_animation_library(parsed.sheet)
let player = @moonpixelanimkit.AnimationPlayer::new(library, clip_name="idle")
let next = player.step(120)
println(next.current_frame().unwrap().name)
}| 功能 | API |
|---|---|
| 解析 Aseprite sprite sheet JSON | parse_sprite_sheet_json(input) |
| 校验资源结构 | validate_sprite_sheet(sheet) / validate_sprite_sheet_json(input) |
| 解析 .ase/.aseprite 基础结构 | parse_aseprite_binary(bytes) |
| 构建动画库 | build_animation_library(sheet) |
| 动画播放推进 | AnimationPlayer::step(delta_ms) |
| 提取 hitbox/hurtbox/collision box | build_frame_box_table(sheet) |
| 导出 runtime manifest | export_runtime_manifest(sheet) |
| 导出 Phaser 动画计划 | export_phaser_animation_plan(sheet) |
| 导出 Canvas draw plan | build_canvas_draw_plan(sheet) |
| 统计 atlas 与动画时长 | analyze_sprite_sheet(sheet) |
| 构建帧时间轴 | build_sheet_timeline(sheet) / build_tag_timeline(sheet, tag) |
| 检查游戏素材策略 | check_asset_policy(sheet, policy) |
| 检查导出目标兼容性 | check_export_compatibility(sheet) / validate_sprite_sheet_json_for_export(input) |
| 检查帧命名序列 | group_frame_names(sheet) / inspect_frame_name_groups(sheet) |
| CLI 报告 | moon run cmd/main |
moon check
moon build
moon test
moon run cmd/main
moon run cmd/main -- --json
moon run cmd/main -- --ase
moon run examples/basic
moon publish --dry-runpub(all) struct AnimationClip {
name : String
direction : TagDirection
loop_mode : LoopMode
frames : Array[AnimationFrameRef]
total_duration_ms : Int
} derive(Eq, Debug)fn AnimationClip::new(name : String, frames : Array[AnimationFrameRef], direction? : TagDirection, loop_mode? : LoopMode) -> AnimationClippub(all) struct AnimationLibrary {
texture_image : String
atlas_size : Size
clips : Array[AnimationClip]
} derive(Eq, Debug)pub(all) struct AnimationPlayer {
library : AnimationLibrary
clip_name : String
frame_cursor : Int
elapsed_in_frame_ms : Int
playing : Bool
completed : Bool
forward : Bool
} derive(Eq, Debug)fn CanvasDrawCommand::new(frame_name : String, source : Rect, destination : Rect, duration_ms : Int) -> CanvasDrawCommandpub(all) struct ExportCompatibilityOptions {
target : RuntimeTarget
require_frame_tags : Bool
require_layer_metadata : Bool
require_slice_boxes : Bool
require_hitbox : Bool
require_hurtbox : Bool
require_collision_box : Bool
require_image_name : Bool
allow_rotated_frames : Bool
allow_trimmed_frames : Bool
max_atlas_width : Int
max_atlas_height : Int
min_frame_duration_ms : Int
max_frame_duration_ms : Int
} derive(Eq, Debug)fn FrameNameParts::new(original : String, stem : String, suffix_number? : Int, has_number? : Bool) -> FrameNamePartspub(all) struct FrameTag {
name : String
from_index : Int
to_index : Int
direction : TagDirection
color : String
user_data : String
} derive(Eq, Debug)fn FrameTag::new(name : String, from_index : Int, to_index : Int, direction? : TagDirection, color? : String, user_data? : String) -> FrameTagfn FrameTimelineEntry::new(frame_index : Int, frame_name : String, start_ms : Int, duration_ms : Int) -> FrameTimelineEntrypub(all) struct PixelAnimError {
kind : PixelAnimErrorKind
path : String
offset : Int
message : String
} derive(Eq, Debug)fn PixelAnimError::new(kind : PixelAnimErrorKind, message : String, path? : String, offset? : Int) -> PixelAnimErrorpub(all) enum PixelAnimErrorKind {
ErrorNone
ErrorJsonParse
ErrorExpectedObject
ErrorMissingField
ErrorInvalidField
ErrorInvalidFrame
ErrorInvalidTag
ErrorInvalidSlice
ErrorInvalidLayer
ErrorNotAseprite
ErrorUnsupportedChunk
ErrorChunkOutOfBounds
ErrorTruncatedData
ErrorUnsupportedCompression
ErrorRuntimeState
ErrorInvalidArgument
} derive(Eq, Debug)pub(all) struct PixelAnimParseResult {
ok : Bool
sheet : SpriteSheet
error : PixelAnimError
} derive(Eq, Debug)pub(all) struct SpriteSheet {
frames : Array[FrameInfo]
meta : SpriteSheetMeta
source_length : Int
} derive(Eq, Debug)pub(all) struct SpriteSheetStats {
frame_count : Int
tag_count : Int
slice_count : Int
layer_count : Int
atlas_area : Int
used_area : Int
utilization_milli : Int
trimmed_frames : Int
rotated_frames : Int
total_duration_ms : Int
shortest_duration_ms : Int
longest_duration_ms : Int
average_duration_ms : Int
} derive(Eq, Debug)pub(all) struct ValidationIssue {
severity : IssueSeverity
path : String
code : String
message : String
} derive(Eq, Debug)pub(all) struct ValidationReport {
ok : Bool
issues : Array[ValidationIssue]
error_count : Int
warning_count : Int
} derive(Eq, Debug)fn check_export_compatibility(sheet : SpriteSheet, options? : ExportCompatibilityOptions) -> ValidationReportfn export_runtime_manifest_from_parts(sheet : SpriteSheet, library : AnimationLibrary, boxes : FrameBoxTable) -> Stringfn has_required_box_kinds(table : FrameBoxTable, require_hit? : Bool, require_hurt? : Bool, require_collision? : Bool) -> Boolfn merge_validation_reports(first : ValidationReport, second : ValidationReport) -> ValidationReportfn timeline_frame_at(entries : Array[FrameTimelineEntry], elapsed_ms : Int, looped? : Bool) -> FrameTimelineEntry?fn validate_sprite_sheet_json_for_export(input : String, options? : ExportCompatibilityOptions) -> ValidationReportMoonBit-native pixel animation asset parser, validator, runtime model, and export toolkit.