SpriteFrames
Named frame animations, textures and relative durations stored as a resource.
Stores data for AnimatedSprite2D and AnimatedSprite3D: clip names, FPS, loop mode, textures and frame-duration weights. A new resource contains a default animation. AddFrame requires an existing name; call AddAnimation first.
Frame duration is a relative weight, not seconds. At nonzero speed, frame time is duration / (FPS × abs(playingSpeed)). Editing a shared resource changes data for every sprite using it. Each entity holds its own playback position.
Complete atlas and timing calculation.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
SpriteFramesConstructor
public SpriteFrames();Properties1
AnimationsProperty
public Reckfell.Collections.Array Animations { get; set; }Methods20
AddAnimationvoid
public void AddAnimation(StringName anim);Creates an empty named animation. The name must not exist; adding it again does not clear an existing clip. Then add frames and set FPS and loop mode.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
animNew unique clip name.
AddFramevoid
public void AddFrame(StringName anim, Texture2D texture, float duration = 1f, int atPosition = -1);Adds a frame texture to an existing clip. duration is a relative weight. A valid atPosition inserts before that frame; a negative position or one at least equal to the frame count appends.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
texture | Texture2D | — |
duration | float | 1f |
atPosition | int | -1 |
animExisting animation name; call HasAnimation first when existence is uncertain.
textureFrame texture, such as an AtlasTexture region sharing an atlas.
durationRelative duration weight, not seconds. Values below 0.01 are raised to 0.01 on insertion. Weight 2 lasts twice as long as 1 at equal FPS and playback speed.
atPositionIndex to insert before. The default -1 appends. An index equal to or above the frame count also appends.
Clearvoid
public void Clear(StringName anim);Removes all frames from the anim animation.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
ClearAllvoid
public void ClearAll();Removes all animations. An empty default animation will be created.
DuplicateAnimationvoid
public void DuplicateAnimation(StringName animFrom, StringName animTo);Duplicates the animation anim_from to a new animation named anim_to. Fails if anim_to already exists, or if anim_from does not exist.
| Name | Type | Default |
|---|---|---|
animFrom | StringName | — |
animTo | StringName | — |
GetAnimationLoopbool · Deprecated
public bool GetAnimationLoop(StringName anim);Obsolete check for the Linear mode specifically. Returns false for Pingpong even though it also loops. Use GetAnimationLoopMode for the full value.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
animExisting animation name; call HasAnimation first when existence is uncertain.
booltrue only for Linear. false does not prove one-shot playback because it includes Pingpong.
GetAnimationLoopModeSpriteFrames.LoopMode
public SpriteFrames.LoopMode GetAnimationLoopMode(StringName anim);Reads a clip loop mode. It does not replace HasAnimation: a missing name reports an engine error and returns None.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
animExisting animation name; call HasAnimation first when existence is uncertain.
SpriteFrames.LoopModeThe LoopMode value. Fallback None for an unknown name does not mean a valid clip was found.
GetAnimationNamesstring[]
public string[] GetAnimationNames();Returns an array containing the names associated to each animation. Values are placed in alphabetical order.
string[]GetAnimationSpeeddouble
public double GetAnimationSpeed(StringName anim);Reads base FPS from the resource, excluding entity-specific SpeedScale and customSpeed.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
animExisting animation name; call HasAnimation first when existence is uncertain.
doubleBase clip FPS. An unknown name reports an engine error and returns 0.
GetFrameCountint
public int GetFrameCount(StringName anim);Returns the selected clip frame count. An existing empty clip has zero frames and does not play through Play.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
animExisting animation name; call HasAnimation first when existence is uncertain.
intFrame count. An unknown name reports an engine error and also returns 0; check HasAnimation separately.
GetFrameDurationfloat
public float GetFrameDuration(StringName anim, int idx);Reads a relative frame weight. At nonzero speed, seconds equal duration / (FPS × abs(playingSpeed)); at zero speed the cursor does not advance.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
idx | int | — |
animExisting animation name; call HasAnimation first when existence is uncertain.
idxZero-based frame index in this clip.
floatRelative weight, not seconds. Weight 2 doubles time relative to weight 1 with the other settings unchanged.
GetFrameTextureTexture2D
public Texture2D GetFrameTexture(StringName anim, int idx);Reads the selected frame texture. An AtlasTexture result holds a region rather than automatically extracting a new image detached from the atlas.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
idx | int | — |
animExisting animation name; call HasAnimation first when existence is uncertain.
idxZero-based frame index; it must be below GetFrameCount(anim).
Texture2DFrame Texture2D, which may be an AtlasTexture. This does not imply exclusive ownership.
HasAnimationbool
public bool HasAnimation(StringName anim);Checks name existence in the library, not frame count or playback state.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
animClip name to test.
booltrue if the name exists, even for an empty clip.
RemoveAnimationvoid
public void RemoveAnimation(StringName anim);Removes the anim animation.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
RemoveFramevoid
public void RemoveFrame(StringName anim, int idx);Removes the anim animation's frame idx.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
idx | int | — |
RenameAnimationvoid
public void RenameAnimation(StringName anim, StringName newname);Changes the anim animation's name to newname.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
newname | StringName | — |
SetAnimationLoopvoid · Deprecated
public void SetAnimationLoop(StringName anim, bool loop);Obsolete boolean method: true selects Linear and false selects None. It cannot select Pingpong. Use SetAnimationLoopMode for new code.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
loop | bool | — |
animExisting animation name; call HasAnimation first when existence is uncertain.
looptrue for Linear, false for None; not a general switch for every looping mode.
SetAnimationLoopModevoid
public void SetAnimationLoopMode(StringName anim, SpriteFrames.LoopMode loopMode);Sets an existing clip loop mode through LoopMode. Prefer this method to obsolete SetAnimationLoop. It edits resource data rather than issuing playback to a specific sprite.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
loopMode | SpriteFrames.LoopMode | — |
animExisting animation name; call HasAnimation first when existence is uncertain.
loopModeNone plays once; Linear repeats from the beginning; Pingpong reverses at boundaries.
SetAnimationSpeedvoid
public void SetAnimationSpeed(StringName anim, double fps);Sets base clip FPS. Zero is accepted and freezes advancement without changing sprite IsPlaying; negative values are rejected. Use AnimatedSprite2D multipliers for reverse playback.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
fps | double | — |
animExisting animation name; call HasAnimation first when existence is uncertain.
fpsNonnegative base FPS. Frame weights and sprite multipliers further change duration.
SetFramevoid
public void SetFrame(StringName anim, int idx, Texture2D texture, float duration = 1f);Sets the texture and the duration of the frame idx in the anim animation. duration specifies the relative duration, see SpriteFrames.GetFrameDuration for details.
| Name | Type | Default |
|---|---|---|
anim | StringName | — |
idx | int | — |
texture | Texture2D | — |
duration | float | 1f |
SpriteFrames.LoopMode
| Value | Description |
|---|---|
Linear = 1 | The animation restarts from the beginning when it reaches the end, or from the end if played in reverse, repeating continuously. |
None = 0 | The animation plays once and stops when it reaches the end, or the start if played in reverse. |
Pingpong = 2 | The animation alternates direction each time it reaches the end or start, playing forward and then in reverse repeatedly.
Note: Both |