SpriteFrame Class
Represents a single frame in a sprite animation.
public class SpriteFrame
Inheritance System.Object → SpriteFrame
| Properties | |
|---|---|
| DrawOffset | Pixel offset applied to the sprite's draw position for this frame. Used by AnimationSystem to compensate for Aseprite trim offsets (spriteSourceSize) so that trimmed frames appear at the correct canvas-relative position. Zero by default (no offset). |
| Duration | Duration to display this frame (in seconds). Minimum 0.001 seconds (1 ms). Automatically invalidates the owning AnimationClip's duration cache when changed. Clips that share this frame are all invalidated via weak references, so a clip that has been abandoned (GC eligible) will not prevent collection. |
| FlipX | Optional per-frame horizontal flip override. When non-null and the layer mask includes Brine2D.Animation.AnimationLayerMask.FlipX, AnimationSystem writes this to FlipX. |
| FlipY | Optional per-frame vertical flip override. When non-null and the layer mask includes Brine2D.Animation.AnimationLayerMask.FlipY, AnimationSystem writes this to FlipY. |
| HitBox | Optional per-frame hit/collision box in local space (pixels, relative to the frame's top-left corner). Shorthand for the named box stored under HitBoxSliceName. |
| NamedHitBoxes | Read-only view of all named hit boxes on this frame. |
| Origin | Origin/pivot point for this frame (relative to frame, 0–1 range). Applied by AnimationSystem to Origin. |
| OwnerClipCount | Gets the number of AnimationClip instances this frame currently belongs to. A value greater than 1 means this frame is shared; mutating Duration will invalidate the TotalDuration cache on all owning clips. |
| SourceRect | Source rectangle in the sprite sheet (in pixels). |
| Texture | Optional pre-loaded texture override for this frame. Takes priority over Texture when non-null. |
| TexturePath | Optional texture path override for this frame. Takes priority over TexturePath when non-null. |
| Tint | Optional per-frame tint override. When non-null and the layer mask includes Brine2D.Animation.AnimationLayerMask.Tint, AnimationSystem writes this to Tint. |
| UserData | Arbitrary per-frame payload. Not consumed by the animation system. |
| Methods | |
|---|---|
| Clone() | Creates a shallow clone of this frame with the same visual properties, hit boxes, and user data. OnEnter and OnExit event subscriptions are \<em>not\</em> copied — the clone starts with no subscribers. The clone is not registered as belonging to any AnimationClip; add it to a clip via AddFrame(SpriteFrame) as normal. |
| GetHitBox(string) | Returns the named hit box, or throws System.Collections.Generic.KeyNotFoundException. |
| RemoveHitBox(string) | Removes the named hit box. Returns true if it existed. |
| SetHitBox(string, Rectangle) | Sets a named hit box. |
| TryGetHitBox(string) | Returns the named hit box if present, or null. |
| Events | |
|---|---|
| OnEnter | Raised once when this frame becomes the active frame. Multiple subscribers are supported; all are invoked in subscription order. |
| OnExit | Raised once when this frame is no longer the active frame. Multiple subscribers are supported; all are invoked in subscription order. |