apply method

  1. @override
void apply(
  1. Skeleton skeleton,
  2. double lastTime,
  3. double time,
  4. List<Event?> events,
  5. double alpha,
  6. MixPose pose,
  7. MixDirection direction
)
override

Implementation

@override
void apply(Skeleton skeleton, double lastTime, double time,
    List<Event?> events, double alpha, MixPose pose, MixDirection direction) {
  final Slot slot = skeleton.slots[slotIndex];
  if (direction == MixDirection.mixOut && pose == MixPose.setup) {
    final String? attachmentName = slot.data.attachmentName;
    slot.setAttachment(attachmentName == null
        ? null
        : skeleton.getAttachment(slotIndex, attachmentName));
    return;
  }

  final Float32List frames = this.frames;
  if (time < frames[0]) {
    if (pose == MixPose.setup) {
      final String? attachmentName = slot.data.attachmentName;
      slot.setAttachment(attachmentName == null
          ? null
          : skeleton.getAttachment(slotIndex, attachmentName));
    }
    return;
  }

  int frameIndex = 0;
  if (time >= frames[frames.length - 1]) {
    frameIndex = frames.length - 1;
  } else {
    frameIndex = Animation.binarySearch(frames, time, 1) - 1;
  }

  final String? attachmentName = attachmentNames[frameIndex];
  skeleton.slots[slotIndex].setAttachment(attachmentName == null
      ? null
      : skeleton.getAttachment(slotIndex, attachmentName));
}