Skip to main content

pite_core/nodes/
animated_sprite2d.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! AnimatedSprite2D: plays 2D flipbook animations from a spritesheet atlas.
3
4use crate::schema::{DefaultPropVal, NodeTypeSchema, PropHint, PropSchema};
5
6pub static SCHEMA: NodeTypeSchema = NodeTypeSchema {
7    type_name: "AnimatedSprite2D",
8    description: "Plays 2D flipbook animations from a spritesheet atlas.",
9    inherits: Some("Node2D"),
10    abstract_class: false,
11    props: PROPS,
12};
13
14pub static PROPS: &[PropSchema] = &[
15    PropSchema {
16        key: "atlas",
17        label: "Atlas",
18        doc: "Path to a spritesheet sidecar (`.atlas.json`).",
19        default_value: DefaultPropVal::Str(""),
20        hint: PropHint::Asset {
21            filter: &["atlas.json", "json"],
22        },
23        read_only: false,
24    },
25    PropSchema {
26        key: "animation",
27        label: "Animation",
28        doc: "Named animation sequence inside the atlas.",
29        default_value: DefaultPropVal::Str(""),
30        hint: PropHint::Text,
31        read_only: false,
32    },
33    PropSchema {
34        key: "frame",
35        label: "Frame",
36        doc: "Current frame index of the playing animation.",
37        default_value: DefaultPropVal::Int(0),
38        hint: PropHint::Int {
39            speed: 1.0,
40            min: 0,
41            max: 9999,
42        },
43        read_only: false,
44    },
45    PropSchema {
46        key: "speed_scale",
47        label: "Speed Scale",
48        doc: "Playback speed multiplier for the animation.",
49        default_value: DefaultPropVal::Num(1.0),
50        hint: PropHint::Num {
51            speed: 0.1,
52            min: -100.0,
53            max: 100.0,
54        },
55        read_only: false,
56    },
57    PropSchema {
58        key: "playing",
59        label: "Playing",
60        doc: "Whether the animation is currently playing.",
61        default_value: DefaultPropVal::Bool(false),
62        hint: PropHint::Bool,
63        read_only: false,
64    },
65    PropSchema {
66        key: "autoplay",
67        label: "Autoplay",
68        doc: "Animation name to begin playing automatically on ready.",
69        default_value: DefaultPropVal::Str(""),
70        hint: PropHint::Text,
71        read_only: false,
72    },
73];