setAnimationByName method

TrackEntry setAnimationByName(
  1. int trackIndex,
  2. String animationName,
  3. bool loop
)

Sets an animation by name.

See setAnimation.

Implementation

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