reckfellENGINE

AnimatedSprite2D

A 2D frame-based sprite with its own playback cursor.

On this page
class AnimatedSprite2DReckfellSharpInherits Entity2D

Plays named animations from SpriteFrames. The resource holds frame data; this entity holds the clip name, Frame, FrameProgress and playback state. Sharing a resource does not share entity cursors, but editing its frames or FPS affects every user.

Play/Pause/Stop control the cursor; IsPlaying can be true at zero speed. Assigning a different SpriteFrames resource stops playback. The sprite does not create a physics shape or gameplay event by itself.

Complete movement example · Timing and frames.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

AnimatedSprite2DConstructor
# AnimatedSprite2D
C#
public AnimatedSprite2D();

Properties10

AnimationProperty
# Animation
C#
public StringName Animation { get; set; }

Selected clip name. Changing it selects the directional start: the first frame for forward playback or the last for reverse playback. This is not a separate Play command or an unconditional reset to zero.

AutoplayProperty
# Autoplay
C#
public string Autoplay { get; set; }

The key of the animation to play when the scene loads.

CenteredProperty
# Centered
C#
public bool Centered { get; set; }

If true, texture will be centered. Note: For games with a pixel art aesthetic, textures may appear deformed when centered. This is caused by their position being between pixels. To prevent this, set this property to false, or consider enabling ProjectSettings.rendering/2d/snap/snap_2d_vertices_to_pixel and ProjectSettings.rendering/2d/snap/snap_2d_transforms_to_pixel.

FlipHProperty
# FlipH
C#
public bool FlipH { get; set; }

If true, texture is flipped horizontally.

FlipVProperty
# FlipV
C#
public bool FlipV { get; set; }

If true, texture is flipped vertically.

FrameProperty
# Frame
C#
public int Frame { get; set; }

Displayed frame index. Assignment also sets FrameProgress to 1 when GetPlayingSpeed is negative, otherwise 0, including while paused. Use SetFrameAndProgress to preserve an explicit fraction.

FrameProgressProperty
# FrameProgress
C#
public float FrameProgress { get; set; }

Current frame fraction, normally increasing from 0 to 1 forward and decreasing from 1 to 0 in reverse. Explicit assignments are not automatically clamped to that interval. Use [0,1] for ordinary cursor positioning.

OffsetProperty
# Offset
C#
public Vector2 Offset { get; set; }

The texture's drawing offset.

SpeedScaleProperty
# SpeedScale
C#
public float SpeedScale { get; set; }

Entity playback multiplier. Direction follows the sign of SpeedScale multiplied by the Play customSpeed. Zero freezes advancement without calling Pause. Stop preserves SpeedScale. This value is not clip FPS.

SpriteFramesProperty
# SpriteFrames
C#
public SpriteFrames SpriteFrames { get; set; }

Source of frames and clips. Assigning a different resource stops playback and resets the cursor; assigning the identical instance again does not reset it. Edits to shared data are visible to other users.

Methods27

GetAnimationStringName
# GetAnimation
C#
public StringName GetAnimation();
Returns StringName
GetAutoplaystring
# GetAutoplay
C#
public string GetAutoplay();
Returns string
GetFrameint
# GetFrame
C#
public int GetFrame();
Returns int
GetFrameProgressfloat
# GetFrameProgress
C#
public float GetFrameProgress();
Returns float
GetOffsetVector2
# GetOffset
C#
public Vector2 GetOffset();
Returns Vector2
GetPlayingSpeedfloat
# GetPlayingSpeed
C#
public float GetPlayingSpeed();

Returns SpeedScale multiplied by customSpeed while playback is enabled, otherwise 0. It excludes clip FPS and relative frame duration.

Returns float

Signed multiplier: negative for reverse playback, zero while paused, stopped or when the product is zero.

GetSpeedScalefloat
# GetSpeedScale
C#
public float GetSpeedScale();
Returns float
GetSpriteFramesSpriteFrames
# GetSpriteFrames
C#
public SpriteFrames GetSpriteFrames();
Returns SpriteFrames
IsCenteredbool
# IsCentered
C#
public bool IsCentered();
Returns bool
IsFlippedHbool
# IsFlippedH
C#
public bool IsFlippedH();
Returns bool
IsFlippedVbool
# IsFlippedV
C#
public bool IsFlippedV();
Returns bool
IsPlayingbool
# IsPlaying
C#
public bool IsPlaying();

Checks the playback flag, not visible advancement. Zero SpeedScale, customSpeed or FPS can leave this true. Pause, Stop and one-shot completion disable playback.

Returns bool

true while playback is enabled; this does not alone guarantee frame changes.

Pausevoid
# Pause
C#
public void Pause();

Disables playback while preserving Frame and FrameProgress. Play of the same clip resumes that cursor using the new call customSpeed. GetPlayingSpeed returns 0 while paused.

Playvoid
# Play
C#
public void Play(StringName name = null, float customSpeed = 1f, bool fromEnd = false);

Plays an existing nonempty clip. Changing the name selects its beginning or end according to fromEnd. The same name resumes the cursor after Pause; every call replaces customSpeed. Use Stop followed by Play for an explicit restart.

Parameters
NameTypeDefault
nameStringNamenull
customSpeedfloat1f
fromEndboolfalse
name

Clip name in SpriteFrames. The default selects the current clip, not the first clip in the library.

customSpeed

Per-call multiplier combined with SpeedScale. Zero prevents advancement; a negative product plays in reverse. A later Play call omitting this argument uses 1 again.

fromEnd

Start at the end when selecting a new clip. This chooses a cursor position, not a reverse direction. Use SetFrameAndProgress for arbitrary positioning within the same clip.

PlayBackwardsvoid
# PlayBackwards
C#
public void PlayBackwards(StringName name = null);

Shorthand for Play(name, -1, true). A positive SpeedScale gives the expected reverse direction; negative SpeedScale reverses the product again. After pausing, the same clip can resume its saved cursor.

Parameters
NameTypeDefault
nameStringNamenull
name

Existing clip name; the default uses the current clip.

SetAnimationvoid
# SetAnimation
C#
public void SetAnimation(StringName name);
Parameters
NameTypeDefault
nameStringName—
SetAutoplayvoid
# SetAutoplay
C#
public void SetAutoplay(string name);
Parameters
NameTypeDefault
namestring—
SetCenteredvoid
# SetCentered
C#
public void SetCentered(bool centered);
Parameters
NameTypeDefault
centeredbool—
SetFlipHvoid
# SetFlipH
C#
public void SetFlipH(bool flipH);
Parameters
NameTypeDefault
flipHbool—
SetFlipVvoid
# SetFlipV
C#
public void SetFlipV(bool flipV);
Parameters
NameTypeDefault
flipVbool—
SetFramevoid
# SetFrame
C#
public void SetFrame(int frame);
Parameters
NameTypeDefault
frameint—
SetFrameAndProgressvoid
# SetFrameAndProgress
C#
public void SetFrameAndProgress(int frame, float progress);

Explicitly sets the frame index and fraction without changing the playback flag. With an existing clip, the index is clamped to available frames; progress is not automatically clamped.

Parameters
NameTypeDefault
frameint—
progressfloat—
frame

Zero-based index. A negative index becomes 0; one beyond an existing clip becomes its last valid frame.

progress

Frame fraction, normally [0,1]: 0 starts forward advancement and 1 starts reverse advancement. The method stores the supplied value without clamping.

SetFrameProgressvoid
# SetFrameProgress
C#
public void SetFrameProgress(float progress);
Parameters
NameTypeDefault
progressfloat—
SetOffsetvoid
# SetOffset
C#
public void SetOffset(Vector2 offset);
Parameters
NameTypeDefault
offsetVector2—
SetSpeedScalevoid
# SetSpeedScale
C#
public void SetSpeedScale(float speedScale);
Parameters
NameTypeDefault
speedScalefloat—
SetSpriteFramesvoid
# SetSpriteFrames
C#
public void SetSpriteFrames(SpriteFrames spriteFrames);
Parameters
NameTypeDefault
spriteFramesSpriteFrames—
Stopvoid
# Stop
C#
public void Stop();

Disables playback, resets Frame and FrameProgress to 0 and customSpeed to 1. Preserves SpeedScale and the selected Animation name. Use Pause to retain the cursor.

Signals and events5

AnimationChangedEvent
# AnimationChanged
C#
public event Action AnimationChanged;

Emitted when AnimatedSprite2D.Animation changes.

AnimationFinishedEvent
# AnimationFinished
C#
public event Action AnimationFinished;

Signals reaching the end of a one-shot clip forward or its beginning in reverse. Playback pauses at that boundary. Use AnimationLooped for loops; awaiting this event on an endless clip does not finish at each cycle.

AnimationLoopedEvent
# AnimationLooped
C#
public event Action AnimationLooped;

Signals crossing a looping clip boundary. Pingpong changes direction there; Linear begins another pass. This is not AnimationFinished or an independent gameplay event.

FrameChangedEvent
# FrameChanged
C#
public event Action FrameChanged;

Sprite frame-change notification, including manual cursor operations. Do not use it as a screen-frame counter or a guarantee of one gameplay effect per action.

SpriteFramesChangedEvent
# SpriteFramesChanged
C#
public event Action SpriteFramesChanged;

Emitted when AnimatedSprite2D.SpriteFrames changes.

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.