Skip to main content
AnimationIterator is a sealed interface that provides iteration over animation keyframes with support for different playback modes.

Package

Type Parameters

  • T - The type of keyframe (must implement Timed)

Methods

clear()

Resets the iterator to its initial state. Since: 1.15.2

type()

Returns the loop type of this animation iterator. Returns: The animation type Since: 1.15.2

hasNext()

Inherited from Iterator<T>. Returns whether more keyframes are available.

next()

Inherited from Iterator<T>. Returns the next keyframe.

Type Enum

The AnimationIterator.Type enum defines animation playback behavior.

Enum Constants

PLAY_ONCE

Plays the animation once and then stops. Serialized as "once". Since: 1.15.2

LOOP

Loops the animation continuously from start to finish. Serialized as "loop". Since: 1.15.2

HOLD_ON_LAST

Plays the animation once and holds the last frame indefinitely. Serialized as "hold". Since: 1.15.2

Type Methods

create(TimedStorage)

Creates a new iterator for the given keyframes based on this type. Parameters:
  • keyframes - The keyframes to iterate over
Returns: A new animation iterator Since: 1.15.2

Implementation Classes

The interface has three sealed implementations:

PlayOnce

Implementation for PLAY_ONCE type. Iterates through keyframes once, then returns false for hasNext().

Loop

Implementation for LOOP type. When reaching the end, resets to the first keyframe and continues infinitely.

HoldOnLast

Implementation for HOLD_ON_LAST type. After reaching the last keyframe, continues returning that frame indefinitely.

Usage Examples

Creating an Iterator

Iterating Through Keyframes

Looping Animation

Hold on Last Frame

Resetting an Iterator

Checking Iterator Type

Using with AnimationModifier

JSON Serialization

The enum values serialize to JSON strings:

See Also