Table of Contents

Class SpriteFrames

Namespace
Godot
Assembly
GodotSharp.dll

Sprite frame library for an AnimatedSprite2D or AnimatedSprite3D node. Contains frames and animation data for playback.

public class SpriteFrames : Resource, IDisposable
Inheritance
SpriteFrames
Implements
Inherited Members

Constructors

SpriteFrames()

public SpriteFrames()

Properties

Animations

public Array Animations { get; set; }

Property Value

Array

Methods

AddAnimation(StringName)

Adds a new anim animation to the library.

public void AddAnimation(StringName anim)

Parameters

anim StringName

AddFrame(StringName, Texture2D, float, int)

Adds a frame to the anim animation. If atPosition is -1, the frame will be added to the end of the animation.

public void AddFrame(StringName anim, Texture2D texture, float duration = 1, int atPosition = -1)

Parameters

anim StringName
texture Texture2D
duration float
atPosition int

Clear(StringName)

Removes all frames from the anim animation.

public void Clear(StringName anim)

Parameters

anim StringName

ClearAll()

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

public void ClearAll()

GetAnimationLoop(StringName)

Returns true if the given animation is configured to loop when it finishes playing. Otherwise, returns false.

public bool GetAnimationLoop(StringName anim)

Parameters

anim StringName

Returns

bool

GetAnimationNames()

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

public string[] GetAnimationNames()

Returns

string[]

GetAnimationSpeed(StringName)

Returns the speed in frames per second for the anim animation.

public double GetAnimationSpeed(StringName anim)

Parameters

anim StringName

Returns

double

GetFrameCount(StringName)

Returns the number of frames for the anim animation.

public int GetFrameCount(StringName anim)

Parameters

anim StringName

Returns

int

GetFrameDuration(StringName, int)

Returns a relative duration of the frame idx in the anim animation (defaults to 1.0). For example, a frame with a duration of 2.0 is displayed twice as long as a frame with a duration of 1.0. You can calculate the absolute duration (in seconds) of a frame using the following formula:

absolute_duration = relative_duration / (animation_fps * abs(playing_speed))

In this example, playing_speed refers to either GetPlayingSpeed() or GetPlayingSpeed().

public float GetFrameDuration(StringName anim, int idx)

Parameters

anim StringName
idx int

Returns

float

GetFrameTexture(StringName, int)

Returns the texture of the frame idx in the anim animation.

public Texture2D GetFrameTexture(StringName anim, int idx)

Parameters

anim StringName
idx int

Returns

Texture2D

HasAnimation(StringName)

Returns true if the anim animation exists.

public bool HasAnimation(StringName anim)

Parameters

anim StringName

Returns

bool

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

RemoveAnimation(StringName)

Removes the anim animation.

public void RemoveAnimation(StringName anim)

Parameters

anim StringName

RemoveFrame(StringName, int)

Removes the anim animation's frame idx.

public void RemoveFrame(StringName anim, int idx)

Parameters

anim StringName
idx int

RenameAnimation(StringName, StringName)

Changes the anim animation's name to newname.

public void RenameAnimation(StringName anim, StringName newname)

Parameters

anim StringName
newname StringName

SetAnimationLoop(StringName, bool)

If loop is true, the anim animation will loop when it reaches the end, or the start if it is played in reverse.

public void SetAnimationLoop(StringName anim, bool loop)

Parameters

anim StringName
loop bool

SetAnimationSpeed(StringName, double)

Sets the speed for the anim animation in frames per second.

public void SetAnimationSpeed(StringName anim, double fps)

Parameters

anim StringName
fps double

SetFrame(StringName, int, Texture2D, float)

Sets the texture and the duration of the frame idx in the anim animation.

public void SetFrame(StringName anim, int idx, Texture2D texture, float duration = 1)

Parameters

anim StringName
idx int
texture Texture2D
duration float