AnimationClip Class
Definition
Namespace: Brine2D.Animation
Represents an animation clip with multiple frames.
Inheritance System.Object → AnimationClip
| Properties | |
|---|---|
| ClipTint | Optional tint applied to Tint while this clip is active. A per-frame Tint takes priority. |
| Events | Read-only view of clip event markers. Use AddEvent\(string, float, Action<ClipEventArgs>, bool\) and RemoveEvent\(string\) to mutate. |
| Frames | Read-only view of frames in this animation. Use AddFrame\(SpriteFrame\), InsertFrame\(int, SpriteFrame\), RemoveFrame\(SpriteFrame\), and ClearFrames() to mutate. |
| Loop | Shorthand for PlaybackMode. Setting to false maps the current mode to its non-looping equivalent: Loop becomes PlaybackMode.Once; PingPong becomes PingPongOnce. Setting to true always sets Loop — use PlaybackMode directly for ping-pong. |
| Name | Name of the animation \(e\.g\., "walk", "jump", "idle"\). |
| PlaybackMode | Controls how the clip loops. Defaults to Loop. |
| RepeatCount | Number of full passes before firing OnAnimationComplete. Only meaningful for Loop and PingPong. 0 \(default\) loops indefinitely. OnLoopComplete fires on each pass regardless. |
| Texture | Optional clip-level pre-loaded texture. Written to Texture each frame. A per-frame Texture takes priority. |
| TexturePath | Optional clip-level texture path. Written to TexturePath each frame. A per-frame TexturePath takes priority. |
| TotalDuration | Total duration in seconds. Cached; invalidated automatically when frames are added, removed, or a frame's Duration changes while it belongs to this clip. |
| UserData | Arbitrary per-clip payload. Use this to attach game-specific data \(e\.g\. clip categories, tags, metadata\) without subclassing. Not consumed by the animation system. |
| Methods | |
|---|---|
| AddEvent\(string, float, Action<ClipEventArgs>, bool\) | Adds a named event marker that fires when playback crosses the given time offset. Events are stored sorted by time. |
| AddEventAtFrame\(string, int, Action<ClipEventArgs>, bool\) | Adds a named event marker that fires when playback reaches the given zero-based frame index. Unlike AddEvent\(string, float, Action<ClipEventArgs>, bool\), the resolved time is automatically kept up-to-date when any frame's Duration changes while it belongs to this clip. |
| AddFrame\(SpriteFrame\) | Appends a frame to the end of the clip. |
| CaptureSnapshot() | Captures a snapshot of this clip's mutable runtime state. Frame lists and events are not included; use Clone\(string\) for a full structural copy. |
| ClearEvents() | Removes all event markers from this clip. |
| ClearFrames() | Removes all frames from the clip. |
| Clone\(string\) | Creates a shallow copy under a new name. Frames are shared, not deep copied. Event callbacks are not copied. |
| FromAtlasRegions\(string, IReadOnlyList<AtlasRegion>, float, PlaybackMode\) | Creates an animation clip from a sequence of AtlasRegions. Each region becomes one frame; the frame's Texture is set to the region's AtlasTexture and SourceRect is set to the region's SourceRect. |
| FromSpriteSheet\(string, int, int, int, int, int, int, float, PlaybackMode, string, ITexture\) | Creates an animation from a sprite sheet with uniform frame sizes. |
| InsertFrame\(int, SpriteFrame\) | Inserts a frame at the specified index. |
| InvalidateDurationCache() | Marks the TotalDuration cache as dirty, forcing a recompute on next access. Also re-resolves the times of any events registered via AddEventAtFrame\(string, int, Action<ClipEventArgs>, bool\) so that frame-index-based events remain accurate after a frame's Duration is mutated. |
| RemoveEvent\(ClipEvent\) | Removes a specific event instance. Use this when multiple events share the same name. |
| RemoveEvent\(string\) | Removes the first event with the given name. |
| RemoveFrame\(SpriteFrame\) | Removes a specific frame from the clip. |
| RestoreSnapshot\(AnimationClipSnapshot\) | Restores a previously captured snapshot. |
| Events | |
|---|---|
| OnEnter | Raised once when this clip becomes the active clip via Play\(string, bool\). |
| OnExit | Raised once when this clip is replaced by a different clip via Play\(string, bool\). |
| OnUpdate | Raised every tick while this clip is the active clip and the animator is playing. Receives the elapsed clip time in seconds. |