Skip to content

AnimationPlayer

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

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

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

Overview

Plays Electron2D.Animation resources against nodes in the scene tree.

Syntax

public sealed class Electron2D.AnimationPlayer : Electron2D.Node

Godot 4.7 C# profile compatibility

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

Node that plays animation libraries, applies value tracks through NodePath, calls method tracks, queues animations and emits animation_finished.

Remarks

Electron2D.AnimationPlayer mounts one or more Electron2D.AnimationLibrary resources, resolves animation names, advances playback during Electron2D.SceneTree processing and applies supported tracks to target nodes.

Electron2D 0.1.0 Preview supports value tracks, method call tracks, FIFO queue playback and the animation_finished signal. Blend trees, editor timeline tooling and audio or 3D-specific tracks are outside this baseline.

Thread Safety

This type is not synchronized. Create and mutate animation players on the main scene thread that owns the node.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation
  • Electron2D.AnimationLibrary

Members

Member Kind Summary
AssignedAnimation Property Gets or sets the animation selected for calls to Electron2D.AnimationPlayer.Play(Electron2D.StringName,System.Double,System.Single,System.Boolean) with an empty name.
Autoplay Property Gets or sets the animation to play automatically when the node is ready.
CurrentAnimation Property Gets the animation currently controlled by playback.
CurrentAnimationLength Property Gets the length of the current animation in seconds.
CurrentAnimationPosition Property Gets the current playback position in seconds.
RootNode Property Gets or sets the node path used as the base for animation track paths.
SpeedScale Property Gets or sets the global playback speed multiplier.
Electron2D.AnimationPlayer() Constructor Creates an animation player with the default root node path.
AddAnimationLibrary(Electron2D.StringName, Electron2D.AnimationLibrary) Method Adds an animation library.
Advance(System.Double) Method Advances playback by a time delta.
ClearQueue() Method Clears the playback queue.
GetAnimationLibrary(Electron2D.StringName) Method Gets an animation library.
GetAnimationLibraryList() Method Gets mounted library names in deterministic alphabetical order.
GetQueue() Method Gets queued animation names.
HasAnimation(Electron2D.StringName) Method Checks whether an animation name resolves through mounted libraries.
HasAnimationLibrary(Electron2D.StringName) Method Checks whether an animation library is mounted.
IsPlaying() Method Gets whether playback is active.
Pause() Method Pauses playback at the current position.
Play(Electron2D.StringName, System.Double, System.Single, System.Boolean) Method Starts playback of an animation.
Queue(Electron2D.StringName) Method Appends an animation to the playback queue.
RemoveAnimationLibrary(Electron2D.StringName) Method Removes an animation library.
Stop(System.Boolean) Method Stops playback.
_Ready() Method Starts autoplay after the player becomes ready.

Member Details

AssignedAnimation

Kind: Property

public Electron2D.StringName AssignedAnimation { get; set; }

Summary

Gets or sets the animation selected for calls to Electron2D.AnimationPlayer.Play(Electron2D.StringName,System.Double,System.Single,System.Boolean) with an empty name.

Remarks

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

Value

The assigned animation name, or an empty value when no animation is assigned.

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.AnimationPlayer

Autoplay

Kind: Property

public Electron2D.StringName Autoplay { get; set; }

Summary

Gets or sets the animation to play automatically when the node is ready.

Remarks

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

Value

The animation name. Use an empty value 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.AnimationPlayer.Play(Electron2D.StringName,System.Double,System.Single,System.Boolean)

CurrentAnimation

Kind: Property

public Electron2D.StringName CurrentAnimation { get; }

Summary

Gets the animation currently controlled by playback.

Remarks

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

Value

The current animation name, or an empty value before playback starts.

Thread Safety

This property is safe to read on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

CurrentAnimationLength

Kind: Property

public System.Double CurrentAnimationLength { get; }

Summary

Gets the length of the current animation in seconds.

Remarks

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

Value

The resolved animation length, or 0 when no current animation is available.

Thread Safety

This property is safe to read on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

CurrentAnimationPosition

Kind: Property

public System.Double CurrentAnimationPosition { get; }

Summary

Gets the current playback position in seconds.

Remarks

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

Value

The current position inside Electron2D.AnimationPlayer.CurrentAnimation.

Thread Safety

This property is safe to read on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

RootNode

Kind: Property

public Electron2D.NodePath RootNode { get; set; }

Summary

Gets or sets the node path used as the base for animation track paths.

Remarks

A value track path such as Target:Position first resolves Electron2D.AnimationPlayer.RootNode, then resolves Target from that root.

Value

A path resolved relative to this player. The default is ...

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.AnimationPlayer

SpeedScale

Kind: Property

public System.Single SpeedScale { get; set; }

Summary

Gets or sets the global playback speed multiplier.

Remarks

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

Value

A finite speed multiplier. The default value is 1.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value 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.AnimationPlayer

Electron2D.AnimationPlayer()

Kind: Constructor

public Electron2D.AnimationPlayer()

Summary

Creates an animation player with the default root node path.

Remarks

The constructor registers the animation_finished signal and sets Electron2D.AnimationPlayer.RootNode to .., so track paths resolve relative to the player's parent by default.

Thread Safety

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

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

AddAnimationLibrary(Electron2D.StringName, Electron2D.AnimationLibrary)

Kind: Method

public Electron2D.Error AddAnimationLibrary(Electron2D.StringName, Electron2D.AnimationLibrary)(Electron2D.StringName name, Electron2D.AnimationLibrary library)

Summary

Adds an animation library.

Remarks

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

Parameters

  • name: The library name. An empty name represents the default library.
  • library: The library to mount.

Returns

Electron2D.Error.Ok on success, Electron2D.Error.InvalidParameter for a null library, or Electron2D.Error.AlreadyExists when the name is already used.

Thread Safety

This method is not synchronized. Mutate the player on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer.RemoveAnimationLibrary(Electron2D.StringName)

Advance(System.Double)

Kind: Method

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

Summary

Advances playback by a time delta.

Remarks

This method is called automatically from Electron2D.SceneTree processing. Calling it manually is useful for deterministic tests and tools that need to advance a player without a full frame.

Parameters

  • delta: The finite, non-negative delta in seconds.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when delta is not finite or is less than 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.AnimationPlayer

ClearQueue()

Kind: Method

public System.Void ClearQueue()()

Summary

Clears the playback queue.

Remarks

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

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.AnimationPlayer.Queue(Electron2D.StringName)

GetAnimationLibrary(Electron2D.StringName)

Kind: Method

public Electron2D.AnimationLibrary GetAnimationLibrary(Electron2D.StringName)(Electron2D.StringName name)

Summary

Gets an animation library.

Remarks

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

Parameters

  • name: The library name. An empty name addresses the default library.

Returns

The mounted library, or null when missing.

Thread Safety

This method is safe to call on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

GetAnimationLibraryList()

Kind: Method

public Electron2D.StringName[] GetAnimationLibraryList()()

Summary

Gets mounted library names in deterministic alphabetical order.

Remarks

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

Returns

An array containing all mounted library names.

Thread Safety

This method is safe to call on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

GetQueue()

Kind: Method

public Electron2D.StringName[] GetQueue()()

Summary

Gets queued animation names.

Remarks

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

Returns

The queued names in playback order.

Thread Safety

This method is safe to call on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer.Queue(Electron2D.StringName)

HasAnimation(Electron2D.StringName)

Kind: Method

public System.Boolean HasAnimation(Electron2D.StringName)(Electron2D.StringName name)

Summary

Checks whether an animation name resolves through mounted libraries.

Remarks

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

Parameters

  • name: A bare animation name for the default library, or library/animation for a named library.

Returns

true when the animation resolves; otherwise, false.

Thread Safety

This method is safe to call on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

HasAnimationLibrary(Electron2D.StringName)

Kind: Method

public System.Boolean HasAnimationLibrary(Electron2D.StringName)(Electron2D.StringName name)

Summary

Checks whether an animation library is mounted.

Remarks

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

Parameters

  • name: The library name. An empty name addresses the default library.

Returns

true when the library exists; otherwise, false.

Thread Safety

This method is safe to call on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

IsPlaying()

Kind: Method

public System.Boolean IsPlaying()()

Summary

Gets whether playback is active.

Remarks

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

Returns

true when playback is active; otherwise, false.

Thread Safety

This method is safe to call on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

Pause()

Kind: Method

public System.Void Pause()()

Summary

Pauses playback at the current position.

Remarks

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

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.AnimationPlayer.Play(Electron2D.StringName,System.Double,System.Single,System.Boolean)
  • Electron2D.AnimationPlayer.Stop(System.Boolean)

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

Kind: Method

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

Summary

Starts playback of an animation.

Remarks

Missing animations leave playback stopped. Value tracks are applied at the starting position immediately; method tracks are not called until time advances across their key times.

Parameters

  • name: The animation to play, or an empty value to use Electron2D.AnimationPlayer.AssignedAnimation.
  • customBlend: Reserved blend time parameter. The 0.1.0 Preview runtime accepts the value but does not blend animations yet.
  • customSpeed: The finite custom speed multiplier.
  • fromEnd: true to start at the end of the animation; otherwise, false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when customBlend or 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.AnimationPlayer.Queue(Electron2D.StringName)
  • Electron2D.AnimationPlayer.Stop(System.Boolean)

Queue(Electron2D.StringName)

Kind: Method

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

Summary

Appends an animation to the playback queue.

Remarks

Missing or empty names are ignored. Queued animations start after the current non-looping animation emits animation_finished.

Parameters

  • name: The animation name to queue.

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.AnimationPlayer.ClearQueue
  • Electron2D.AnimationPlayer.GetQueue

RemoveAnimationLibrary(Electron2D.StringName)

Kind: Method

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

Summary

Removes an animation library.

Remarks

Removing a missing library is a no-op.

Parameters

  • name: The library name. An empty name addresses the default library.

Thread Safety

This method is not synchronized. Mutate the player on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

Stop(System.Boolean)

Kind: Method

public System.Void Stop(System.Boolean)(System.Boolean keepState)

Summary

Stops playback.

Remarks

When keepState is false, value tracks are applied at time 0 if the current animation can still be resolved.

Parameters

  • keepState: true to keep the current position; false to reset to the beginning of the current 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.AnimationPlayer.Pause

_Ready()

Kind: Method

public System.Void _Ready()()

Summary

Starts autoplay after the player becomes ready.

Remarks

If Electron2D.AnimationPlayer.Autoplay is not empty, this callback calls Electron2D.AnimationPlayer.Play(Electron2D.StringName,System.Double,System.Single,System.Boolean) with that animation name.

Thread Safety

This callback is invoked on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationPlayer

Clone this wiki locally