reckfellENGINE

SpriteFrames

Named frame animations, textures and relative durations stored as a resource.

On this page
class SpriteFramesReckfellSharpInherits 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
# SpriteFrames
C#
public SpriteFrames();

Properties1

AnimationsProperty
# Animations
C#
public Reckfell.Collections.Array Animations { get; set; }

Methods20

AddAnimationvoid
# AddAnimation
C#
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.

Parameters
NameTypeDefault
animStringName—
anim

New unique clip name.

AddFramevoid
# AddFrame
C#
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.

Parameters
NameTypeDefault
animStringName—
textureTexture2D—
durationfloat1f
atPositionint-1
anim

Existing animation name; call HasAnimation first when existence is uncertain.

texture

Frame texture, such as an AtlasTexture region sharing an atlas.

duration

Relative 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.

atPosition

Index to insert before. The default -1 appends. An index equal to or above the frame count also appends.

Clearvoid
# Clear
C#
public void Clear(StringName anim);

Removes all frames from the anim animation.

Parameters
NameTypeDefault
animStringName—
ClearAllvoid
# ClearAll
C#
public void ClearAll();

Removes all animations. An empty default animation will be created.

DuplicateAnimationvoid
# DuplicateAnimation
C#
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.

Parameters
NameTypeDefault
animFromStringName—
animToStringName—
GetAnimationLoopbool · Deprecated
# GetAnimationLoop
C#
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.

Parameters
NameTypeDefault
animStringName—
anim

Existing animation name; call HasAnimation first when existence is uncertain.

Returns bool

true only for Linear. false does not prove one-shot playback because it includes Pingpong.

GetAnimationLoopModeSpriteFrames.LoopMode
# GetAnimationLoopMode
C#
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.

Parameters
NameTypeDefault
animStringName—
anim

Existing animation name; call HasAnimation first when existence is uncertain.

Returns SpriteFrames.LoopMode

The LoopMode value. Fallback None for an unknown name does not mean a valid clip was found.

GetAnimationNamesstring[]
# GetAnimationNames
C#
public string[] GetAnimationNames();

Returns an array containing the names associated to each animation. Values are placed in alphabetical order.

Returns string[]
GetAnimationSpeeddouble
# GetAnimationSpeed
C#
public double GetAnimationSpeed(StringName anim);

Reads base FPS from the resource, excluding entity-specific SpeedScale and customSpeed.

Parameters
NameTypeDefault
animStringName—
anim

Existing animation name; call HasAnimation first when existence is uncertain.

Returns double

Base clip FPS. An unknown name reports an engine error and returns 0.

GetFrameCountint
# GetFrameCount
C#
public int GetFrameCount(StringName anim);

Returns the selected clip frame count. An existing empty clip has zero frames and does not play through Play.

Parameters
NameTypeDefault
animStringName—
anim

Existing animation name; call HasAnimation first when existence is uncertain.

Returns int

Frame count. An unknown name reports an engine error and also returns 0; check HasAnimation separately.

GetFrameDurationfloat
# GetFrameDuration
C#
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.

Parameters
NameTypeDefault
animStringName—
idxint—
anim

Existing animation name; call HasAnimation first when existence is uncertain.

idx

Zero-based frame index in this clip.

Returns float

Relative weight, not seconds. Weight 2 doubles time relative to weight 1 with the other settings unchanged.

GetFrameTextureTexture2D
# GetFrameTexture
C#
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.

Parameters
NameTypeDefault
animStringName—
idxint—
anim

Existing animation name; call HasAnimation first when existence is uncertain.

idx

Zero-based frame index; it must be below GetFrameCount(anim).

Returns Texture2D

Frame Texture2D, which may be an AtlasTexture. This does not imply exclusive ownership.

HasAnimationbool
# HasAnimation
C#
public bool HasAnimation(StringName anim);

Checks name existence in the library, not frame count or playback state.

Parameters
NameTypeDefault
animStringName—
anim

Clip name to test.

Returns bool

true if the name exists, even for an empty clip.

RemoveAnimationvoid
# RemoveAnimation
C#
public void RemoveAnimation(StringName anim);

Removes the anim animation.

Parameters
NameTypeDefault
animStringName—
RemoveFramevoid
# RemoveFrame
C#
public void RemoveFrame(StringName anim, int idx);

Removes the anim animation's frame idx.

Parameters
NameTypeDefault
animStringName—
idxint—
RenameAnimationvoid
# RenameAnimation
C#
public void RenameAnimation(StringName anim, StringName newname);

Changes the anim animation's name to newname.

Parameters
NameTypeDefault
animStringName—
newnameStringName—
SetAnimationLoopvoid · Deprecated
# SetAnimationLoop
C#
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.

Parameters
NameTypeDefault
animStringName—
loopbool—
anim

Existing animation name; call HasAnimation first when existence is uncertain.

loop

true for Linear, false for None; not a general switch for every looping mode.

SetAnimationLoopModevoid
# SetAnimationLoopMode
C#
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.

Parameters
NameTypeDefault
animStringName—
loopModeSpriteFrames.LoopMode—
anim

Existing animation name; call HasAnimation first when existence is uncertain.

loopMode

None plays once; Linear repeats from the beginning; Pingpong reverses at boundaries.

SetAnimationSpeedvoid
# SetAnimationSpeed
C#
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.

Parameters
NameTypeDefault
animStringName—
fpsdouble—
anim

Existing animation name; call HasAnimation first when existence is uncertain.

fps

Nonnegative base FPS. Frame weights and sprite multipliers further change duration.

SetFramevoid
# SetFrame
C#
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.

Parameters
NameTypeDefault
animStringName—
idxint—
textureTexture2D—
durationfloat1f

SpriteFrames.LoopMode

ValueDescription
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 AnimatedSprite2D and AnimatedSprite3D play the first/last frame for its duration only once at each end of the animation loop (instead of twice, once per forward/backward animation direction).

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.