2D Toolkit Forum

2D Toolkit => Support => Topic started by: luniac on November 28, 2014, 11:27:32 pm

Title: Animation Events Example in JS
Post by: luniac on November 28, 2014, 11:27:32 pm

Hi, can i get a basic example of using animation events in JS?

The documentation code is in C#
anim.AnimationEventTriggered = HandleAnimationEvent;

    void HandleAnimationEvent(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip, int frameNo) {
        tk2dSpriteAnimationFrame frame = clip.GetFrame( frameNo );
        Debug.Log( frame.eventInt );
    }



I get that i attach the script to the object with the spriteanimator but the example JS script doesn't have any event callback syntax, and I'm not sure how to do it.

http://www.unikronsoftware.com/2dtoolkit/docs/latest/tutorial/scripting_a_sprite_animator.html

Is there some simple way to check callback like:
OnAnimationEvent(eventdata : data){
 if(eventdata.info = FRAME3){
    CODE
 }
}


I just need a super basic example. Thanks :)
Title: Re: Animation Events Example in JS
Post by: unikronsoftware on November 29, 2014, 11:26:29 am
Similar to this UI stuff -
http://2dtoolkit.com/forum/index.php/topic,1835.0.html