#pragma once #include #include #include #include #include namespace extra2d { // ============================================================================ // CompositeAnimation - ALS 多层复合动画节点 // 管理多个 AnimationNode 图层,统一控制播放 // 对应 DNF 的 ALS 格式(多层动画叠加) // ============================================================================ class CompositeAnimation : public Node { public: CompositeAnimation() = default; ~CompositeAnimation() override = default; // ------ 静态工厂 ------ static Ptr create(); static Ptr create(const std::string &alsFilePath); // ------ 加载 ------ bool loadFromFile(const std::string &alsFilePath); // ------ 图层管理 ------ void addLayer(Ptr node, int zOrder = 0); void removeLayer(size_t index); Ptr getLayer(size_t index) const; Ptr getMainLayer() const; size_t getLayerCount() const; // ------ 统一播放控制 ------ void play(); void pause(); void resume(); void stop(); void reset(); void setPlaybackSpeed(float speed); void setLooping(bool loop); bool isPlaying() const; bool isStopped() const; // ------ 事件回调(绑定到主图层)------ void setKeyframeCallback(KeyframeHitCallback callback); void setCompletionCallback(AnimationCompleteCallback callback); void addEventListener(AnimationEventCallback callback); // ------ 视觉属性(应用到所有图层)------ void setTintColor(const Color &color); void setFlipX(bool flip); void setFlipY(bool flip); private: struct LayerEntry { Ptr node; int zOrder = 0; }; std::vector layers_; }; } // namespace extra2d