Class AnimatedSprite3D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
AnimatedSprite3D is similar to the Sprite3D node, except it carries multiple textures as animation SpriteFrames. Animations are created using a SpriteFrames resource, which allows you to import image files (or a folder containing said files) to provide the animation frames for the sprite. The SpriteFrames resource can be configured in the editor via the SpriteFrames bottom panel.
public class AnimatedSprite3D : SpriteBase3D, IDisposable
- Inheritance
-
AnimatedSprite3D
- Implements
- Inherited Members
Constructors
AnimatedSprite3D()
public AnimatedSprite3D()
Properties
Animation
The current animation from the SpriteFrames resource. If this value is changed, the Frame counter and the FrameProgress are reset.
public StringName Animation { get; set; }
Property Value
Autoplay
The key of the animation to play when the scene loads.
public string Autoplay { get; set; }
Property Value
Frame
The displayed animation frame's index. Setting this property also resets FrameProgress. If this is not desired, use SetFrameAndProgress(int, float).
public int Frame { get; set; }
Property Value
FrameProgress
The progress value between 0.0
and 1.0
until the current frame transitions to the next frame. If the animation is playing backwards, the value transitions from 1.0
to 0.0
.
public float FrameProgress { get; set; }
Property Value
SpeedScale
The speed scaling ratio. For example, if this value is 1
, then the animation plays at normal speed. If it's 0.5
, then it plays at half speed. If it's 2
, then it plays at double speed.
If set to a negative value, the animation is played in reverse. If set to 0
, the animation will not advance.
public float SpeedScale { get; set; }
Property Value
SpriteFrames
The SpriteFrames resource containing the animation(s). Allows you the option to load, edit, clear, make unique and save the states of the SpriteFrames resource.
public SpriteFrames SpriteFrames { get; set; }
Property Value
Methods
GetPlayingSpeed()
Returns the actual playing speed of current animation or 0
if not playing. This speed is the SpeedScale property multiplied by custom_speed
argument specified when calling the Play(StringName, float, bool) method.
Returns a negative value if the current animation is playing backwards.
public float GetPlayingSpeed()
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
method
godot_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
signal
godot_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
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsPlaying()
Returns true
if an animation is currently playing (even if SpeedScale and/or custom_speed
are 0
).
public bool IsPlaying()
Returns
Pause()
Pauses the currently playing animation. The Frame and FrameProgress will be kept and calling Play(StringName, float, bool) or PlayBackwards(StringName) without arguments will resume the animation from the current playback position.
See also Stop().
public void Pause()
Play(StringName, float, bool)
Plays the animation with key name
. If customSpeed
is negative and fromEnd
is true
, the animation will play backwards (which is equivalent to calling PlayBackwards(StringName)).
If this method is called with that same animation name
, or with no name
parameter, the assigned animation will resume playing if it was paused.
public void Play(StringName name = null, float customSpeed = 1, bool fromEnd = false)
Parameters
name
StringNamecustomSpeed
floatfromEnd
bool
PlayBackwards(StringName)
Plays the animation with key name
in reverse.
This method is a shorthand for Play(StringName, float, bool) with custom_speed = -1.0
and from_end = true
, so see its description for more information.
public void PlayBackwards(StringName name = null)
Parameters
name
StringName
SetFrameAndProgress(int, float)
The setter of Frame resets the FrameProgress to 0.0
implicitly, but this method avoids that.
This is useful when you want to carry over the current FrameProgress to another Frame.
Example:
public void SetFrameAndProgress(int frame, float progress)
Parameters
Stop()
Stops the currently playing animation. The animation position is reset to 0
and the custom_speed
is reset to 1.0
. See also Pause().
public void Stop()
Events
AnimationChanged
Emitted when Animation changes.
public event Action AnimationChanged
Event Type
AnimationFinished
Emitted when the animation reaches the end, or the start if it is played in reverse. When the animation finishes, it pauses the playback.
public event Action AnimationFinished
Event Type
AnimationLooped
Emitted when the animation loops.
public event Action AnimationLooped
Event Type
FrameChanged
Emitted when Frame changes.
public event Action FrameChanged
Event Type
SpriteFramesChanged
Emitted when SpriteFrames changes.
public event Action SpriteFramesChanged