addAnimationByName method

TrackEntry addAnimationByName(
  1. int trackIndex,
  2. String animationName,
  3. bool loop,
  4. double delay,
)

Adds an animation to be played delay seconds after the current or last queued animation for a track. If the track is empty, it is equivalent to calling setAnimation. @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation duration of the previous track minus any mix duration plus the negative delay.

@return A track entry to allow further customization of animation playback. References to the track entry must not be kept after AnimationState.Dispose

Implementation

TrackEntry addAnimationByName(int trackIndex, String animationName, bool loop, double delay) {
  final animation = animationName.toNativeUtf8(allocator: _allocator);
  final entry = _bindings.spine_animation_state_add_animation_by_name(
      _state, trackIndex, animation.cast(), loop ? -1 : 0, delay);
  _allocator.free(animation);
  if (entry.address == nullptr.address) throw Exception("Couldn't add animation $animationName");
  return TrackEntry._(entry, this);
}