Skip to content

Animation

Eduard Gushchin edited this page Jun 21, 2026 · 5 revisions

Animation

Back to API Reference

Namespace: Electron2D

Summary

Stores keyframed value and method-call tracks for Electron2D.AnimationPlayer.

Declaration

public sealed class Electron2D.Animation : Electron2D.Resource

Remarks

An Electron2D.Animation is a passive resource. It stores ordered tracks, key times, key values and method-call entries, but it does not advance time or modify scene nodes by itself.

Electron2D 0.1.0 Preview supports value tracks and method tracks only. Editor-only tracks, audio tracks, section playback and blend-tree data are outside this runtime baseline.

Thread Safety

This type is not synchronized. Mutate an instance from one thread, normally during loading or on the main scene thread. Read-only access is safe only while no thread is mutating the resource.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimationLibrary
  • Electron2D.AnimationPlayer

Members

Member Kind Summary
Length Property Gets or sets the animation length in seconds.
LoopMode Property Gets or sets the loop mode used by Electron2D.AnimationPlayer.
Electron2D.Animation() Constructor Creates an empty animation resource.
AddTrack(Electron2D.Animation.TrackTypeEnum, System.Int32) Method Adds a new track.
GetTrackCount() Method Gets the number of tracks stored in this resource.
MethodTrackInsertKey(System.Int32, System.Double, Electron2D.StringName, Electron2D.Variant[]) Method Inserts or replaces a method-call key.
RemoveTrack(System.Int32) Method Removes a track.
TrackGetInterpolationType(System.Int32) Method Gets the interpolation mode for a value track.
TrackGetKeyCount(System.Int32) Method Gets the number of keys in a track.
TrackGetKeyTime(System.Int32, System.Int32) Method Gets a key time.
TrackGetKeyValue(System.Int32, System.Int32) Method Gets a value key's Variant value.
TrackGetPath(System.Int32) Method Gets the path assigned to a track.
TrackGetType(System.Int32) Method Gets the kind of a track.
TrackInsertKey(System.Int32, System.Double, Electron2D.Variant) Method Inserts or replaces a value key.
TrackIsEnabled(System.Int32) Method Gets whether a track is enabled.
TrackSetEnabled(System.Int32, System.Boolean) Method Enables or disables a track.
TrackSetInterpolationType(System.Int32, Electron2D.Animation.InterpolationTypeEnum) Method Sets the interpolation mode for a value track.
TrackSetPath(System.Int32, Electron2D.NodePath) Method Assigns a path to a track.
ValueTrackInterpolate(System.Int32, System.Double) Method Evaluates a value track at a specific time.

Member Details

Length

Kind: Property

public System.Double Length { get; set; }

Summary

Gets or sets the animation length in seconds.

Remarks

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

Value

A finite value greater than or equal to 0.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the assigned value is not finite or is less than 0.

Thread Safety

This property is not synchronized. Mutate it from one thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation

LoopMode

Kind: Property

public Electron2D.Animation.LoopModeEnum LoopMode { get; set; }

Summary

Gets or sets the loop mode used by Electron2D.AnimationPlayer.

Remarks

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

Value

The loop behavior for playback of this resource.

Thread Safety

This property is not synchronized. Mutate it from one thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation

Electron2D.Animation()

Kind: Constructor

public Electron2D.Animation()

Summary

Creates an empty animation resource.

Remarks

New animations have a length of 0, no tracks and Electron2D.Animation.LoopModeEnum.None loop behavior.

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

AddTrack(Electron2D.Animation.TrackTypeEnum, System.Int32)

Kind: Method

public System.Int32 AddTrack(Electron2D.Animation.TrackTypeEnum, System.Int32)(Electron2D.Animation.TrackTypeEnum type, System.Int32 atPosition)

Summary

Adds a new track.

Remarks

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

Parameters

  • type: The kind of track to add.
  • atPosition: The insertion index, or -1 to append the track.

Returns

The zero-based index of the inserted track.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when type is outside the supported enum range or atPosition is outside the insertion range.

Thread Safety

This method is not synchronized. Mutate the resource from one thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.RemoveTrack(System.Int32)

GetTrackCount()

Kind: Method

public System.Int32 GetTrackCount()()

Summary

Gets the number of tracks stored in this resource.

Remarks

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

Returns

The track count.

Thread Safety

This method is safe when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation

MethodTrackInsertKey(System.Int32, System.Double, Electron2D.StringName, Electron2D.Variant[])

Kind: Method

public System.Void MethodTrackInsertKey(System.Int32, System.Double, Electron2D.StringName, Electron2D.Variant[])(System.Int32 trackIdx, System.Double time, Electron2D.StringName method, Electron2D.Variant[] arguments)

Summary

Inserts or replaces a method-call key.

Remarks

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

Parameters

  • trackIdx: The zero-based method track index.
  • time: The finite key time in seconds. It must be at least 0.
  • method: The method name to call on the track target.
  • arguments: The optional method arguments stored as Variant values.

Exceptions

  • System.ArgumentException: Thrown when method is empty.
  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range or time is not finite or less than 0.
  • System.InvalidOperationException: Thrown when trackIdx does not reference a method track.

Thread Safety

This method is not synchronized. Mutate the resource from one thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation

RemoveTrack(System.Int32)

Kind: Method

public System.Void RemoveTrack(System.Int32)(System.Int32 trackIdx)

Summary

Removes a track.

Remarks

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

Parameters

  • trackIdx: The zero-based track index.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range.

Thread Safety

This method is not synchronized. Mutate the resource from one thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.AddTrack(Electron2D.Animation.TrackTypeEnum,System.Int32)

TrackGetInterpolationType(System.Int32)

Kind: Method

public Electron2D.Animation.InterpolationTypeEnum TrackGetInterpolationType(System.Int32)(System.Int32 trackIdx)

Summary

Gets the interpolation mode for a value track.

Remarks

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

Parameters

  • trackIdx: The zero-based track index.

Returns

The interpolation mode.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range.
  • System.InvalidOperationException: Thrown when trackIdx does not reference a value track.

Thread Safety

This method is safe when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.TrackSetInterpolationType(System.Int32,Electron2D.Animation.InterpolationTypeEnum)

TrackGetKeyCount(System.Int32)

Kind: Method

public System.Int32 TrackGetKeyCount(System.Int32)(System.Int32 trackIdx)

Summary

Gets the number of keys in a track.

Remarks

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

Parameters

  • trackIdx: The zero-based track index.

Returns

The number of keys in the track.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range.

Thread Safety

This method is safe when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation

TrackGetKeyTime(System.Int32, System.Int32)

Kind: Method

public System.Double TrackGetKeyTime(System.Int32, System.Int32)(System.Int32 trackIdx, System.Int32 keyIdx)

Summary

Gets a key time.

Remarks

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

Parameters

  • trackIdx: The zero-based track index.
  • keyIdx: The zero-based key index.

Returns

The key time in seconds.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx or keyIdx is outside the valid range.

Thread Safety

This method is safe when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation

TrackGetKeyValue(System.Int32, System.Int32)

Kind: Method

public Electron2D.Variant TrackGetKeyValue(System.Int32, System.Int32)(System.Int32 trackIdx, System.Int32 keyIdx)

Summary

Gets a value key's Variant value.

Remarks

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

Parameters

  • trackIdx: The zero-based value track index.
  • keyIdx: The zero-based key index.

Returns

The stored key value.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx or keyIdx is outside the valid range.
  • System.InvalidOperationException: Thrown when trackIdx does not reference a value track.

Thread Safety

This method is safe when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.TrackInsertKey(System.Int32,System.Double,Electron2D.Variant)

TrackGetPath(System.Int32)

Kind: Method

public Electron2D.NodePath TrackGetPath(System.Int32)(System.Int32 trackIdx)

Summary

Gets the path assigned to a track.

Remarks

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

Parameters

  • trackIdx: The zero-based track index.

Returns

The track path.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range.

Thread Safety

This method is safe when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.TrackSetPath(System.Int32,Electron2D.NodePath)

TrackGetType(System.Int32)

Kind: Method

public Electron2D.Animation.TrackTypeEnum TrackGetType(System.Int32)(System.Int32 trackIdx)

Summary

Gets the kind of a track.

Remarks

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

Parameters

  • trackIdx: The zero-based track index.

Returns

The track type.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range.

Thread Safety

This method is safe when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation

TrackInsertKey(System.Int32, System.Double, Electron2D.Variant)

Kind: Method

public System.Void TrackInsertKey(System.Int32, System.Double, Electron2D.Variant)(System.Int32 trackIdx, System.Double time, Electron2D.Variant value)

Summary

Inserts or replaces a value key.

Remarks

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

Parameters

  • trackIdx: The zero-based value track index.
  • time: The finite key time in seconds. It must be at least 0.
  • value: The value stored at the key.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range or time is not finite or less than 0.
  • System.InvalidOperationException: Thrown when trackIdx does not reference a value track.

Thread Safety

This method is not synchronized. Mutate the resource from one thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.ValueTrackInterpolate(System.Int32,System.Double)

TrackIsEnabled(System.Int32)

Kind: Method

public System.Boolean TrackIsEnabled(System.Int32)(System.Int32 trackIdx)

Summary

Gets whether a track is enabled.

Remarks

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

Parameters

  • trackIdx: The zero-based track index.

Returns

true when the track is enabled; otherwise, false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range.

Thread Safety

This method is safe when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.TrackSetEnabled(System.Int32,System.Boolean)

TrackSetEnabled(System.Int32, System.Boolean)

Kind: Method

public System.Void TrackSetEnabled(System.Int32, System.Boolean)(System.Int32 trackIdx, System.Boolean enabled)

Summary

Enables or disables a track.

Remarks

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

Parameters

  • trackIdx: The zero-based track index.
  • enabled: true to enable the track; otherwise, false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range.

Thread Safety

This method is not synchronized. Mutate the resource from one thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.TrackIsEnabled(System.Int32)

TrackSetInterpolationType(System.Int32, Electron2D.Animation.InterpolationTypeEnum)

Kind: Method

public System.Void TrackSetInterpolationType(System.Int32, Electron2D.Animation.InterpolationTypeEnum)(System.Int32 trackIdx, Electron2D.Animation.InterpolationTypeEnum interpolation)

Summary

Sets the interpolation mode for a value track.

Remarks

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

Parameters

  • trackIdx: The zero-based track index.
  • interpolation: The interpolation mode to assign.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range or interpolation is outside the supported enum range.
  • System.InvalidOperationException: Thrown when trackIdx does not reference a value track.

Thread Safety

This method is not synchronized. Mutate the resource from one thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.TrackGetInterpolationType(System.Int32)

TrackSetPath(System.Int32, Electron2D.NodePath)

Kind: Method

public System.Void TrackSetPath(System.Int32, Electron2D.NodePath)(System.Int32 trackIdx, Electron2D.NodePath path)

Summary

Assigns a path to a track.

Remarks

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

Parameters

  • trackIdx: The zero-based track index.
  • path: The target path. Value tracks use node path plus property subnames; method tracks use the node path.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range.

Thread Safety

This method is not synchronized. Mutate the resource from one thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.TrackGetPath(System.Int32)

ValueTrackInterpolate(System.Int32, System.Double)

Kind: Method

public Electron2D.Variant ValueTrackInterpolate(System.Int32, System.Double)(System.Int32 trackIdx, System.Double time)

Summary

Evaluates a value track at a specific time.

Remarks

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

Parameters

  • trackIdx: The zero-based value track index.
  • time: The finite time in seconds.

Returns

The nearest or interpolated value. A track with no keys returns a nil Electron2D.Variant.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when trackIdx is outside the track range or time is not finite.
  • System.InvalidOperationException: Thrown when trackIdx does not reference a value track.

Thread Safety

This method is safe when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Animation.TrackInsertKey(System.Int32,System.Double,Electron2D.Variant)
  • Electron2D.Animation.TrackSetInterpolationType(System.Int32,Electron2D.Animation.InterpolationTypeEnum)

Clone this wiki locally