SpriteFactory.Sprite.SetAnimationFinishedCallback
C#: void SetAnimationFinishedCallback (string animationName, System.Action callback)
JS: function SetAnimationFinishedCallback (animationName : String, callback : System.Action) : void
Description
Assign a callback to run when an animation finishes playing. Use this to take some action after an animation finishes playing. This will never be called when animation wrapMode is set to Clamp, inifinite Loop, or infinite PingPong.
Example:
C#
void Start() { // Set up callbacks for when animations finish playing sprite.SetAnimationFinishedCallback("Jab", AttackAnimFinished); sprite.SetAnimationFinishedCallback("BodyBlow", AttackAnimFinished); sprite.SetAnimationFinishedCallback("Uppercut", AttackAnimFinished); } private void AttackAnimFinished() { // do something Debug.Log("Attack animation finished"); }JS
function Start() : void { // Set up callbacks for when animations finish playing sprite.SetAnimationFinishedCallback("Jab", AttackAnimFinished); sprite.SetAnimationFinishedCallback("BodyBlow", AttackAnimFinished); sprite.SetAnimationFinishedCallback("Uppercut", AttackAnimFinished); } function AttackAnimFinished() : void { // do something Debug.Log("Attack animation finished"); }
C#: void SetAnimationFinishedCallback (int animationIndex, System.Action callback)
JS: function SetAnimationFinishedCallback (animationIndex : int, callback : System.Action) : void
Description
Assign a callback to run when an animation finishes playing. Use this to take some action after an animation finishes playing. This will never be called when animation wrapMode is set to Clamp, inifinite Loop, or infinite PingPong.
Example:
C#
void Start() { // Set up callbacks for when animations finish playing sprite.SetAnimationFinishedCallback(0, AttackAnimFinished); sprite.SetAnimationFinishedCallback(1, AttackAnimFinished); sprite.SetAnimationFinishedCallback(2, AttackAnimFinished); } private void AttackAnimFinished() { // do something Debug.Log("Attack animation finished"); }JS
function Start() : void { // Set up callbacks for when animations finish playing sprite.SetAnimationFinishedCallback(0, AttackAnimFinished); sprite.SetAnimationFinishedCallback(1, AttackAnimFinished); sprite.SetAnimationFinishedCallback(2, AttackAnimFinished); } function AttackAnimFinished() : void { // do something Debug.Log("Attack animation finished"); }
See Also
SetAnimationStartedCallback
SetAnimationEndedCallback