How to play animation using Button event in cocos creator

How to play animation using Button event in cocos creator
0

I need to make an urgent move when on click event I need to set an animation in typescript urgent help

i found The solution ,

  1. Make a clean new Typescript,

  2. create a subclass

  3. use
    example(){
    var anim = this.getComponent(cc.Animation)
    anim.play(“the animation name”)
    }

  4. save this script

  5. attach to node

  6. drag your node to button event and find the class you create

  7. save and play wallllaaaah it works

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.