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
Methods
AddAnimation(StringName)
Adds a new anim animation to the library.
public void AddAnimation(StringName anim)
Parameters
animStringName
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
animStringNametextureTexture2DdurationfloatatPositionint
Clear(StringName)
Removes all frames from the anim animation.
public void Clear(StringName anim)
Parameters
animStringName
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
animStringName
Returns
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
animStringName
Returns
GetFrameCount(StringName)
Returns the number of frames for the anim animation.
public int GetFrameCount(StringName anim)
Parameters
animStringName
Returns
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
animStringNameidxint
Returns
GetFrameTexture(StringName, int)
Returns the texture of the frame idx in the anim animation.
public Texture2D GetFrameTexture(StringName anim, int idx)
Parameters
animStringNameidxint
Returns
HasAnimation(StringName)
Returns true if the anim animation exists.
public bool HasAnimation(StringName anim)
Parameters
animStringName
Returns
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
methodgodot_string_nameName of the method to check for.
Returns
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
signalgodot_string_nameName of the signal to check for.
Returns
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
methodgodot_string_nameName of the method to invoke.
argsNativeVariantPtrArgsArguments to use with the invoked method.
retgodot_variantValue returned by the invoked method.
Returns
RemoveAnimation(StringName)
Removes the anim animation.
public void RemoveAnimation(StringName anim)
Parameters
animStringName
RemoveFrame(StringName, int)
Removes the anim animation's frame idx.
public void RemoveFrame(StringName anim, int idx)
Parameters
animStringNameidxint
RenameAnimation(StringName, StringName)
Changes the anim animation's name to newname.
public void RenameAnimation(StringName anim, StringName newname)
Parameters
animStringNamenewnameStringName
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
animStringNameloopbool
SetAnimationSpeed(StringName, double)
Sets the speed for the anim animation in frames per second.
public void SetAnimationSpeed(StringName anim, double fps)
Parameters
animStringNamefpsdouble
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
animStringNameidxinttextureTexture2Ddurationfloat