/// <summary> /// Create a new animation clip play instance. /// </summary> /// <param name="clip">Which animation clip to play.</param> /// <param name="speed">Animation playing speed.</param> /// <param name="startingStep">Optional starting step index.</param> public SpriteAnimationClipPlay(SpriteAnimationClip clip, float speed = 1f, int?startingStep = null) { Clip = clip; SpeedFactor = speed; CurrentStep = clip.StartIndex + startingStep ?? 0; _timeForNextStep = clip.DelayForStep(CurrentStep - Clip.StartIndex); }
/// <summary> /// Play animation clip. /// </summary> /// <param name="clip">Animation clip to play.</param> /// <param name="speed">Animation playing speed.</param> /// <param name="startingStep">Animation starting step.</param> public void PlayAnimation(SpriteAnimationClip clip, float speed = 1f, int?startingStep = null) { _currAnimation = new SpriteAnimationClipPlay(clip, speed, startingStep); _currAnimation.OnAnimationEnd = () => { this.OnAnimationEnd?.Invoke(); }; }