Skip to content

AnimatedSprite2D

Eduard Gushchin edited this page Jul 1, 2026 · 5 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.AnimatedSprite2D
Namespace Electron2D
Kind class
Category Animation and Tweening

Overview

Displays and advances a texture-frame animation from a Electron2D.AnimatedSprite2D.SpriteFrames resource.

Syntax

public class Electron2D.AnimatedSprite2D : Electron2D.Node2D

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Partial / Not verified
Out of profile: yes
Godot reference: AnimatedSprite2D

Frame-based 2D animation node with SpriteFrames, autoplay, play/pause/stop, frame progress, loop handling and canvas submission of the current frame.

Remarks

Electron2D.AnimatedSprite2D is a 2D canvas node for simple frame-based animations. It reads frame textures from Electron2D.AnimatedSprite2D.SpriteFrames, updates playback state during Electron2D.Node._Process(System.Double), and submits the current frame to the canvas renderer.

The node does not inherit from Electron2D.Sprite2D because its public API intentionally omits direct texture and region editing properties.

Thread Safety

This type is not synchronized. Create and mutate nodes on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.SpriteFrames
  • Electron2D.Node2D

Members

Member Kind Summary
Animation Property Gets or sets the current animation name.
Autoplay Property Gets or sets the animation that starts automatically when the node becomes ready.
Centered Property Gets or sets whether the current frame is drawn centered on the node origin.
FlipH Property Gets or sets whether the current frame is flipped horizontally.
FlipV Property Gets or sets whether the current frame is flipped vertically.
Frame Property Gets or sets the current frame index.
FrameProgress Property Gets or sets the normalized progress through the current frame.
Offset Property Gets or sets the local drawing offset.
SpeedScale Property Gets or sets the playback speed multiplier.
SpriteFrames Property Gets or sets the sprite-frame library used by this node.
Electron2D.AnimatedSprite2D() Constructor Creates a new animated sprite node.
GetPlayingSpeed() Method Gets the current playing speed.
GetRect() Method Gets the local rectangle occupied by the current frame.
IsPixelOpaque(Electron2D.Vector2) Method Checks whether a local sprite position maps to an opaque pixel.
IsPlaying() Method Gets whether playback is active.
Pause() Method Pauses playback while preserving frame position.
Play(Electron2D.StringName, System.Single, System.Boolean) Method Starts or resumes playback.
PlayBackwards(Electron2D.StringName) Method Starts reverse playback.
SetFrameAndProgress(System.Int32, System.Single) Method Sets the current frame and progress together.
Stop() Method Stops playback and resets playback state.
_Process(System.Double) Method Advances playback during the process step.
_Ready() Method Starts autoplay when the node becomes ready.

Member Details

Animation

Kind: Property

public Electron2D.StringName Animation { get; set; }

Summary

Gets or sets the current animation name.

Remarks

Changing this property resets Electron2D.AnimatedSprite2D.Frame and Electron2D.AnimatedSprite2D.FrameProgress to the beginning of the animation.

Value

The animation name inside Electron2D.AnimatedSprite2D.SpriteFrames. The default is default.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean)

Autoplay

Kind: Property

public System.String Autoplay { get; set; }

Summary

Gets or sets the animation that starts automatically when the node becomes ready.

Remarks

This property follows the validation and lifetime rules of its declaring type.

Value

The animation name to pass to Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean) from Electron2D.Node._Ready, or an empty string to disable autoplay.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean)

Centered

Kind: Property

public System.Boolean Centered { get; set; }

Summary

Gets or sets whether the current frame is drawn centered on the node origin.

Remarks

This property follows the validation and lifetime rules of its declaring type.

Value

true to center the frame; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.GetRect

FlipH

Kind: Property

public System.Boolean FlipH { get; set; }

Summary

Gets or sets whether the current frame is flipped horizontally.

Remarks

This property follows the validation and lifetime rules of its declaring type.

Value

true to flip the frame horizontally; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D

FlipV

Kind: Property

public System.Boolean FlipV { get; set; }

Summary

Gets or sets whether the current frame is flipped vertically.

Remarks

This property follows the validation and lifetime rules of its declaring type.

Value

true to flip the frame vertically; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D

Frame

Kind: Property

public System.Int32 Frame { get; set; }

Summary

Gets or sets the current frame index.

Remarks

Setting this property resets Electron2D.AnimatedSprite2D.FrameProgress to 0. Use Electron2D.AnimatedSprite2D.SetFrameAndProgress(System.Int32,System.Single) to preserve a progress value.

Value

The zero-based frame index for Electron2D.AnimatedSprite2D.Animation.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned frame is negative.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.FrameProgress

FrameProgress

Kind: Property

public System.Single FrameProgress { get; set; }

Summary

Gets or sets the normalized progress through the current frame.

Remarks

This property follows the validation and lifetime rules of its declaring type.

Value

A value from 0 to 1. Forward playback moves toward 1; reverse playback moves toward 0.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned progress is not finite or outside 0..1.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.SetFrameAndProgress(System.Int32,System.Single)

Offset

Kind: Property

public Electron2D.Vector2 Offset { get; set; }

Summary

Gets or sets the local drawing offset.

Remarks

This property follows the validation and lifetime rules of its declaring type.

Value

The offset applied before the centered or top-left frame rectangle is calculated.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.GetRect

SpeedScale

Kind: Property

public System.Single SpeedScale { get; set; }

Summary

Gets or sets the playback speed multiplier.

Remarks

This property follows the validation and lifetime rules of its declaring type.

Value

The multiplier applied to the custom speed from Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean). Negative values play in reverse. A value of 0 keeps playback active but stops frame advancement.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned speed is not finite.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.GetPlayingSpeed

SpriteFrames

Kind: Property

public Electron2D.SpriteFrames SpriteFrames { get; set; }

Summary

Gets or sets the sprite-frame library used by this node.

Remarks

Replacing or mutating this resource affects the next process/submission pass without recreating the node.

Value

The assigned Electron2D.AnimatedSprite2D.SpriteFrames resource, or null when the node has no animation data.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.SpriteFrames

Electron2D.AnimatedSprite2D()

Kind: Constructor

public Electron2D.AnimatedSprite2D()

Summary

Creates a new animated sprite node.

Remarks

The node starts on the default animation, frame 0, with playback stopped.

Thread Safety

Construction is safe on any thread when the node is not shared until after construction completes.

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D

GetPlayingSpeed()

Kind: Method

public System.Single GetPlayingSpeed()()

Summary

Gets the current playing speed.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Returns

Electron2D.AnimatedSprite2D.SpeedScale multiplied by the custom speed supplied to Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean) when playback is active; otherwise, 0.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.IsPlaying

GetRect()

Kind: Method

public Electron2D.Rect2 GetRect()()

Summary

Gets the local rectangle occupied by the current frame.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Returns

The frame rectangle in local coordinates, or an empty rectangle when no frame texture is available.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D

IsPixelOpaque(Electron2D.Vector2)

Kind: Method

public System.Boolean IsPixelOpaque(Electron2D.Vector2)(Electron2D.Vector2 position)

Summary

Checks whether a local sprite position maps to an opaque pixel.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Parameters

  • position: The local position to query.

Returns

true if the current frame has an opaque pixel at position; otherwise, false.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.GetRect

IsPlaying()

Kind: Method

public System.Boolean IsPlaying()()

Summary

Gets whether playback is active.

Remarks

This method can return true even when Electron2D.AnimatedSprite2D.SpeedScale or the custom speed from Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean) is 0.

Returns

true when playback has been started and not paused or stopped; otherwise, false.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.Pause
  • Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean)

Pause()

Kind: Method

public System.Void Pause()()

Summary

Pauses playback while preserving frame position.

Remarks

Calling Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean) without a new animation name resumes from the current frame and progress.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean)
  • Electron2D.AnimatedSprite2D.Stop

Play(Electron2D.StringName, System.Single, System.Boolean)

Kind: Method

public System.Void Play(Electron2D.StringName, System.Single, System.Boolean)(Electron2D.StringName name, System.Single customSpeed, System.Boolean fromEnd)

Summary

Starts or resumes playback.

Remarks

If the selected animation is missing or has no frames, playback remains stopped.

Parameters

  • name: The animation to play, or an empty value to use the current Electron2D.AnimatedSprite2D.Animation.
  • customSpeed: The finite custom speed multiplier for this playback request.
  • fromEnd: true to begin at the last frame of the selected animation.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when customSpeed is not finite.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.Pause
  • Electron2D.AnimatedSprite2D.PlayBackwards(Electron2D.StringName)

PlayBackwards(Electron2D.StringName)

Kind: Method

public System.Void PlayBackwards(Electron2D.StringName)(Electron2D.StringName name)

Summary

Starts reverse playback.

Remarks

This method is equivalent to calling Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean) with a custom speed of -1 and fromEnd set to true.

Parameters

  • name: The animation to play backwards, or an empty value to use the current Electron2D.AnimatedSprite2D.Animation.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean)

SetFrameAndProgress(System.Int32, System.Single)

Kind: Method

public System.Void SetFrameAndProgress(System.Int32, System.Single)(System.Int32 frame, System.Single progress)

Summary

Sets the current frame and progress together.

Remarks

This method follows the validation and lifetime rules of its declaring type.

Parameters

  • frame: The non-negative frame index.
  • progress: The normalized progress from 0 to 1.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when frame is negative or progress is not finite or outside 0..1.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.Frame
  • Electron2D.AnimatedSprite2D.FrameProgress

Stop()

Kind: Method

public System.Void Stop()()

Summary

Stops playback and resets playback state.

Remarks

This resets Electron2D.AnimatedSprite2D.Frame and Electron2D.AnimatedSprite2D.FrameProgress to 0, and resets the custom speed used by Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean).

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.Pause

_Process(System.Double)

Kind: Method

public System.Void _Process(System.Double)(System.Double delta)

Summary

Advances playback during the process step.

Remarks

The current frame is advanced before the scene draw traversal submits canvas commands for the frame.

Parameters

  • delta: The elapsed process time in seconds.

Thread Safety

This callback is invoked on the main scene thread during scene-tree traversal.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.Frame
  • Electron2D.AnimatedSprite2D.FrameProgress

_Ready()

Kind: Method

public System.Void _Ready()()

Summary

Starts autoplay when the node becomes ready.

Remarks

If Electron2D.AnimatedSprite2D.Autoplay is not empty, this callback calls Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean) with that animation name after the base ready callback has run.

Thread Safety

This callback is invoked on the main scene thread during scene-tree traversal.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D.Autoplay
  • Electron2D.AnimatedSprite2D.Play(Electron2D.StringName,System.Single,System.Boolean)

Clone this wiki locally