ScaleTimeline.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Spine
  4. {
  5. public class ScaleTimeline : TranslateTimeline
  6. {
  7. public ScaleTimeline(int frameCount) : base(frameCount)
  8. {
  9. }
  10. public override void Apply(Skeleton skeleton, float lastTime, float time, List<Event> firedEvents, float alpha)
  11. {
  12. float[] frames = this.frames;
  13. if (time < frames[0])
  14. {
  15. return;
  16. }
  17. Bone bone = skeleton.bones[this.boneIndex];
  18. if (time >= frames[frames.Length - 3])
  19. {
  20. bone.scaleX += (bone.data.scaleX * frames[frames.Length - 2] - bone.scaleX) * alpha;
  21. bone.scaleY += (bone.data.scaleY * frames[frames.Length - 1] - bone.scaleY) * alpha;
  22. return;
  23. }
  24. int num = Animation.binarySearch(frames, time, 3);
  25. float num2 = frames[num - 2];
  26. float num3 = frames[num - 1];
  27. float num4 = frames[num];
  28. float num5 = 1f - (time - num4) / (frames[num + -3] - num4);
  29. num5 = base.GetCurvePercent(num / 3 - 1, (num5 >= 0f) ? ((num5 <= 1f) ? num5 : 1f) : 0f);
  30. bone.scaleX += (bone.data.scaleX * (num2 + (frames[num + 1] - num2) * num5) - bone.scaleX) * alpha;
  31. bone.scaleY += (bone.data.scaleY * (num3 + (frames[num + 2] - num3) * num5) - bone.scaleY) * alpha;
  32. }
  33. }
  34. }