private void ontk2dSpriteAnimatorCallback_Completed(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip) { if (_animationFinishCallbacks != null) { if (_animationFinishCallbacks.ContainsKey(clip)) { UserAnimationCallbackInfos userCallbackInfos = _animationFinishCallbacks[clip]; _animationFinishCallbacks.Remove(clip); userCallbackInfos.func(userCallbackInfos.animationName); } } }
virtual public void PlayAnimation(string animationName, EntityAnimationDirection animationDirection, float fps = 0.0f, Action <string> callback = null) { tk2dSpriteAnimationClip clip; if (animationDirection == null) { clip = animator.GetClipByName(animationName); } else { if (animationDirection.flipX) { animator.transform.localScale = new Vector3(-1, 1, 1); } else { animator.transform.localScale = new Vector3(1, 1, 1); } //animator.Sprite.FlipX = animationDirection.flipX; clip = animator.GetClipByName(animationName + "_" + animationDirection.direction); } Assert.Should(clip != null, animationName + ",animationDirection:" + animationDirection); if (callback != null) { if (_animationFinishCallbacks == null) { _animationFinishCallbacks = new Dictionary <tk2dSpriteAnimationClip, UserAnimationCallbackInfos>(); } UserAnimationCallbackInfos infos = new UserAnimationCallbackInfos() { func = callback, animationName = animationName }; _animationFinishCallbacks.Add(clip, infos); } animator.Play(clip); SetAnimatorFpsFactor(fps); }