Skip to content

SpriteFrames

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

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

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

Overview

Stores named texture-frame animations for Electron2D.AnimatedSprite2D.

Syntax

public sealed class Electron2D.SpriteFrames : Electron2D.Resource

Remarks

A Electron2D.SpriteFrames resource owns animation names, frame textures, relative frame durations, playback speeds and loop modes. The resource does not run playback by itself; Electron2D.AnimatedSprite2D consumes it during scene processing.

A new instance always contains an empty animation named default.

Thread Safety

This type is not synchronized. Mutate it during loading or on the main scene thread. Read-only access is safe from another thread only when no thread is mutating the resource.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AnimatedSprite2D
  • Electron2D.Texture2D

Members

Member Kind Summary
Electron2D.SpriteFrames() Constructor Creates a new sprite-frame library with an empty default animation.
AddAnimation(Electron2D.StringName) Method Adds an empty animation.
AddFrame(Electron2D.StringName, Electron2D.Texture2D, System.Single, System.Int32) Method Adds a frame to an animation.
Clear(Electron2D.StringName) Method Removes all frames from one animation.
ClearAll() Method Removes all animations and recreates an empty default animation.
DuplicateAnimation(Electron2D.StringName, Electron2D.StringName) Method Duplicates an animation into a new animation name.
GetAnimationLoop(Electron2D.StringName) Method Gets whether an animation uses linear looping.
GetAnimationLoopMode(Electron2D.StringName) Method Gets the loop mode for an animation.
GetAnimationNames() Method Gets animation names in deterministic alphabetical order.
GetAnimationSpeed(Electron2D.StringName) Method Gets the speed of an animation in frames per second.
GetFrameCount(Electron2D.StringName) Method Gets the number of frames in an animation.
GetFrameDuration(Electron2D.StringName, System.Int32) Method Gets a frame's relative duration.
GetFrameTexture(Electron2D.StringName, System.Int32) Method Gets a frame's texture.
HasAnimation(Electron2D.StringName) Method Checks whether an animation exists.
RemoveAnimation(Electron2D.StringName) Method Removes an animation.
RemoveFrame(Electron2D.StringName, System.Int32) Method Removes one frame from an animation.
RenameAnimation(Electron2D.StringName, Electron2D.StringName) Method Renames an animation.
SetAnimationLoop(Electron2D.StringName, System.Boolean) Method Sets whether an animation uses linear looping.
SetAnimationLoopMode(Electron2D.StringName, Electron2D.SpriteFrames.LoopModeEnum) Method Sets the loop mode for an animation.
SetAnimationSpeed(Electron2D.StringName, System.Single) Method Sets the speed of an animation in frames per second.
SetFrame(Electron2D.StringName, System.Int32, Electron2D.Texture2D, System.Single) Method Replaces one frame in an animation.

Member Details

Electron2D.SpriteFrames()

Kind: Constructor

public Electron2D.SpriteFrames()

Summary

Creates a new sprite-frame library with an empty default animation.

Remarks

The default animation uses linear looping and a speed of five frames per second.

Thread Safety

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

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames

AddAnimation(Electron2D.StringName)

Kind: Method

public System.Void AddAnimation(Electron2D.StringName)(Electron2D.StringName animation)

Summary

Adds an empty animation.

Remarks

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

Parameters

  • animation: The non-empty animation name to add.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.InvalidOperationException: Thrown when an animation with the same name already exists.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.HasAnimation(Electron2D.StringName)
  • Electron2D.SpriteFrames.RemoveAnimation(Electron2D.StringName)

AddFrame(Electron2D.StringName, Electron2D.Texture2D, System.Single, System.Int32)

Kind: Method

public System.Void AddFrame(Electron2D.StringName, Electron2D.Texture2D, System.Single, System.Int32)(Electron2D.StringName animation, Electron2D.Texture2D texture, System.Single duration, System.Int32 atPosition)

Summary

Adds a frame to an animation.

Remarks

The absolute frame duration in seconds is calculated by Electron2D.AnimatedSprite2D from the relative duration, animation speed and playing speed.

Parameters

  • animation: The animation that receives the frame.
  • texture: The texture to display for the frame.
  • duration: The positive relative frame duration.
  • atPosition: The insertion index, or -1 to append the frame.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.ArgumentNullException: Thrown when texture is null.
  • System.ArgumentOutOfRangeException: Thrown when duration is not finite or not greater than zero, or when atPosition is outside the valid insertion range.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.GetFrameTexture(Electron2D.StringName,System.Int32)
  • Electron2D.SpriteFrames.SetFrame(Electron2D.StringName,System.Int32,Electron2D.Texture2D,System.Single)

Clear(Electron2D.StringName)

Kind: Method

public System.Void Clear(Electron2D.StringName)(Electron2D.StringName animation)

Summary

Removes all frames from one animation.

Remarks

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

Parameters

  • animation: The animation to clear.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.ClearAll

ClearAll()

Kind: Method

public System.Void ClearAll()()

Summary

Removes all animations and recreates an empty default animation.

Remarks

This keeps the resource in a valid state for nodes whose Electron2D.AnimatedSprite2D.Animation is still set to default.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.Clear(Electron2D.StringName)

DuplicateAnimation(Electron2D.StringName, Electron2D.StringName)

Kind: Method

public System.Void DuplicateAnimation(Electron2D.StringName, Electron2D.StringName)(Electron2D.StringName animationFrom, Electron2D.StringName animationTo)

Summary

Duplicates an animation into a new animation name.

Remarks

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

Parameters

  • animationFrom: The existing animation to copy.
  • animationTo: The new animation name.

Exceptions

  • System.ArgumentException: Thrown when either animation name is empty.
  • System.InvalidOperationException: Thrown when animationFrom does not exist or animationTo already exists.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.RenameAnimation(Electron2D.StringName,Electron2D.StringName)

GetAnimationLoop(Electron2D.StringName)

Kind: Method

public System.Boolean GetAnimationLoop(Electron2D.StringName)(Electron2D.StringName animation)

Summary

Gets whether an animation uses linear looping.

Remarks

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

Parameters

  • animation: The animation name.

Returns

true when Electron2D.SpriteFrames.GetAnimationLoopMode(Electron2D.StringName) returns Electron2D.SpriteFrames.LoopModeEnum.Linear; otherwise, false.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

This method is safe to call from any thread when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.GetAnimationLoopMode(Electron2D.StringName)
  • Electron2D.SpriteFrames.SetAnimationLoop(Electron2D.StringName,System.Boolean)

GetAnimationLoopMode(Electron2D.StringName)

Kind: Method

public Electron2D.SpriteFrames.LoopModeEnum GetAnimationLoopMode(Electron2D.StringName)(Electron2D.StringName animation)

Summary

Gets the loop mode for an animation.

Remarks

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

Parameters

  • animation: The animation name.

Returns

The loop mode assigned to the animation.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

This method is safe to call from any thread when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.SetAnimationLoopMode(Electron2D.StringName,Electron2D.SpriteFrames.LoopModeEnum)

GetAnimationNames()

Kind: Method

public Electron2D.StringName[] GetAnimationNames()()

Summary

Gets animation names in deterministic alphabetical order.

Remarks

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

Returns

An array containing all animation names.

Thread Safety

This method is safe to call from any thread when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.AddAnimation(Electron2D.StringName)

GetAnimationSpeed(Electron2D.StringName)

Kind: Method

public System.Single GetAnimationSpeed(Electron2D.StringName)(Electron2D.StringName animation)

Summary

Gets the speed of an animation in frames per second.

Remarks

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

Parameters

  • animation: The animation name.

Returns

The animation speed in frames per second.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

This method is safe to call from any thread when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.SetAnimationSpeed(Electron2D.StringName,System.Single)

GetFrameCount(Electron2D.StringName)

Kind: Method

public System.Int32 GetFrameCount(Electron2D.StringName)(Electron2D.StringName animation)

Summary

Gets the number of frames in an animation.

Remarks

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

Parameters

  • animation: The animation name.

Returns

The frame count for the animation.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

This method is safe to call from any thread when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.AddFrame(Electron2D.StringName,Electron2D.Texture2D,System.Single,System.Int32)

GetFrameDuration(Electron2D.StringName, System.Int32)

Kind: Method

public System.Single GetFrameDuration(Electron2D.StringName, System.Int32)(Electron2D.StringName animation, System.Int32 index)

Summary

Gets a frame's relative duration.

Remarks

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

Parameters

  • animation: The animation name.
  • index: The zero-based frame index.

Returns

The positive relative frame duration.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.ArgumentOutOfRangeException: Thrown when index is outside the animation frame range.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

This method is safe to call from any thread when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.SetFrame(Electron2D.StringName,System.Int32,Electron2D.Texture2D,System.Single)

GetFrameTexture(Electron2D.StringName, System.Int32)

Kind: Method

public Electron2D.Texture2D GetFrameTexture(Electron2D.StringName, System.Int32)(Electron2D.StringName animation, System.Int32 index)

Summary

Gets a frame's texture.

Remarks

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

Parameters

  • animation: The animation name.
  • index: The zero-based frame index.

Returns

The texture assigned to the frame.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.ArgumentOutOfRangeException: Thrown when index is outside the animation frame range.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

This method is safe to call from any thread when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.AddFrame(Electron2D.StringName,Electron2D.Texture2D,System.Single,System.Int32)

HasAnimation(Electron2D.StringName)

Kind: Method

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

Summary

Checks whether an animation exists.

Remarks

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

Parameters

  • animation: The animation name to check.

Returns

true when the resource contains animation; otherwise, false.

Thread Safety

This method is safe to call from any thread when no thread is mutating the resource.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.AddAnimation(Electron2D.StringName)

RemoveAnimation(Electron2D.StringName)

Kind: Method

public System.Void RemoveAnimation(Electron2D.StringName)(Electron2D.StringName animation)

Summary

Removes an animation.

Remarks

Removing the final animation recreates an empty default animation.

Parameters

  • animation: The animation to remove.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.AddAnimation(Electron2D.StringName)

RemoveFrame(Electron2D.StringName, System.Int32)

Kind: Method

public System.Void RemoveFrame(Electron2D.StringName, System.Int32)(Electron2D.StringName animation, System.Int32 index)

Summary

Removes one frame from an animation.

Remarks

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

Parameters

  • animation: The animation that owns the frame.
  • index: The zero-based frame index to remove.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.ArgumentOutOfRangeException: Thrown when index is outside the animation frame range.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.AddFrame(Electron2D.StringName,Electron2D.Texture2D,System.Single,System.Int32)

RenameAnimation(Electron2D.StringName, Electron2D.StringName)

Kind: Method

public System.Void RenameAnimation(Electron2D.StringName, Electron2D.StringName)(Electron2D.StringName animation, Electron2D.StringName newName)

Summary

Renames an animation.

Remarks

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

Parameters

  • animation: The existing animation name.
  • newName: The new animation name.

Exceptions

  • System.ArgumentException: Thrown when either animation name is empty.
  • System.InvalidOperationException: Thrown when animation does not exist or newName already exists.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.DuplicateAnimation(Electron2D.StringName,Electron2D.StringName)

SetAnimationLoop(Electron2D.StringName, System.Boolean)

Kind: Method

public System.Void SetAnimationLoop(Electron2D.StringName, System.Boolean)(Electron2D.StringName animation, System.Boolean loop)

Summary

Sets whether an animation uses linear looping.

Remarks

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

Parameters

  • animation: The animation name.
  • loop: true to set Electron2D.SpriteFrames.LoopModeEnum.Linear; false to set Electron2D.SpriteFrames.LoopModeEnum.None.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.GetAnimationLoop(Electron2D.StringName)
  • Electron2D.SpriteFrames.SetAnimationLoopMode(Electron2D.StringName,Electron2D.SpriteFrames.LoopModeEnum)

SetAnimationLoopMode(Electron2D.StringName, Electron2D.SpriteFrames.LoopModeEnum)

Kind: Method

public System.Void SetAnimationLoopMode(Electron2D.StringName, Electron2D.SpriteFrames.LoopModeEnum)(Electron2D.StringName animation, Electron2D.SpriteFrames.LoopModeEnum loopMode)

Summary

Sets the loop mode for an animation.

Remarks

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

Parameters

  • animation: The animation name.
  • loopMode: The loop mode to assign.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.GetAnimationLoopMode(Electron2D.StringName)

SetAnimationSpeed(Electron2D.StringName, System.Single)

Kind: Method

public System.Void SetAnimationSpeed(Electron2D.StringName, System.Single)(Electron2D.StringName animation, System.Single fps)

Summary

Sets the speed of an animation in frames per second.

Remarks

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

Parameters

  • animation: The animation name.
  • fps: The positive finite speed in frames per second.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.ArgumentOutOfRangeException: Thrown when fps is not finite or not greater than zero.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.GetAnimationSpeed(Electron2D.StringName)

SetFrame(Electron2D.StringName, System.Int32, Electron2D.Texture2D, System.Single)

Kind: Method

public System.Void SetFrame(Electron2D.StringName, System.Int32, Electron2D.Texture2D, System.Single)(Electron2D.StringName animation, System.Int32 index, Electron2D.Texture2D texture, System.Single duration)

Summary

Replaces one frame in an animation.

Remarks

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

Parameters

  • animation: The animation that owns the frame.
  • index: The zero-based frame index to replace.
  • texture: The replacement texture.
  • duration: The positive relative frame duration.

Exceptions

  • System.ArgumentException: Thrown when animation is empty.
  • System.ArgumentNullException: Thrown when texture is null.
  • System.ArgumentOutOfRangeException: Thrown when index is outside the animation frame range, or when duration is not finite or not greater than zero.
  • System.InvalidOperationException: Thrown when animation does not exist.

Thread Safety

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

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.SpriteFrames.GetFrameDuration(Electron2D.StringName,System.Int32)
  • Electron2D.SpriteFrames.GetFrameTexture(Electron2D.StringName,System.Int32)

Clone this wiki locally