addAnimation method

TrackEntry addAnimation(
  1. int trackIndex,
  2. Animation animation,
  3. bool loop,
  4. double delay,
)

Adds an animation to be played after the current or last queued animation for a track at trackIndex. If the track is empty, it is equivalent to calling setAnimation.

If delay > 0, sets TrackEntry.getDelay. If delay <= 0, the delay set is the duration of the previous track entry minus any mix duration (from the AnimationStateData) plus the specified delay (ie the mix ends at (delay = 0) or before (delay < 0) the previous track entry duration). If the previous entry is looping, its next loop completion is used instead of its duration.

Returns a track entry to allow further customization of animation playback. References to the track entry must not be kept after the EventType.dispose event occurs.

Implementation

TrackEntry addAnimation(int trackIndex, Animation animation, bool loop, double delay) {
  final entry = _bindings.spine_animation_state_add_animation(_state, trackIndex, animation._animation, loop ? -1 : 0, delay);
  if (entry.address == nullptr.address) throw Exception("Couldn't add animation ${animation.getName()}");
  return TrackEntry._(entry, this);
}