Class AnimatedTexture
- Namespace
- Godot
- Assembly
- GodotSharp.dll
AnimatedTexture is a resource format for frame-based animations, where multiple textures can be chained automatically with a predefined delay for each frame. Unlike AnimationPlayer or AnimatedSprite2D, it isn't a Node, but has the advantage of being usable anywhere a Texture2D resource can be used, e.g. in a TileSet.
The playback of the animation is controlled by the SpeedScale property, as well as each frame's duration (see SetFrameDuration(int, float)). The animation loops, i.e. it will restart at frame 0 automatically after playing the last frame.
AnimatedTexture currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one.
Note: AnimatedTexture doesn't support using AtlasTextures. Each frame needs to be a separate Texture2D.
Warning: The current implementation is not efficient for the modern renderers.
Deprecated. This class is deprecated, and might be removed in a future release.
[Obsolete("This class is deprecated.")]
public class AnimatedTexture : Texture2D, IDisposable
- Inheritance
-
AnimatedTexture
- Implements
- Inherited Members
Constructors
AnimatedTexture()
public AnimatedTexture()
Fields
MaxFrames
The maximum number of frames supported by AnimatedTexture. If you need more frames in your animation, use AnimationPlayer or AnimatedSprite2D.
public const long MaxFrames = 256
Field Value
Properties
CurrentFrame
Sets the currently visible frame of the texture. Setting this frame while playing resets the current frame time, so the newly selected frame plays for its whole configured frame duration.
public int CurrentFrame { get; set; }
Property Value
Frames
Number of frames to use in the animation. While you can create the frames independently with SetFrameTexture(int, Texture2D), you need to set this value for the animation to take new frames into account. The maximum number of frames is MaxFrames.
public int Frames { get; set; }
Property Value
OneShot
If true
, the animation will only play once and will not loop back to the first frame after reaching the end. Note that reaching the end will not set Pause to true
.
public bool OneShot { get; set; }
Property Value
Pause
If true
, the animation will pause where it currently is (i.e. at CurrentFrame). The animation will continue from where it was paused when changing this property to false
.
public bool Pause { get; set; }
Property Value
SpeedScale
The animation speed is multiplied by this value. If set to a negative value, the animation is played in reverse.
public float SpeedScale { get; set; }
Property Value
Methods
GetFrameDuration(int)
Returns the given frame
's duration, in seconds.
public float GetFrameDuration(int frame)
Parameters
frame
int
Returns
GetFrameTexture(int)
Returns the given frame's Texture2D.
public Texture2D GetFrameTexture(int frame)
Parameters
frame
int
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
SetFrameDuration(int, float)
Sets the duration of any given frame
. The final duration is affected by the SpeedScale. If set to 0
, the frame is skipped during playback.
public void SetFrameDuration(int frame, float duration)
Parameters
SetFrameTexture(int, Texture2D)
Assigns a Texture2D to the given frame. Frame IDs start at 0, so the first frame has ID 0, and the last frame of the animation has ID Frames - 1.
You can define any number of textures up to MaxFrames, but keep in mind that only frames from 0 to Frames - 1 will be part of the animation.
public void SetFrameTexture(int frame, Texture2D texture)