Charactor.js 675 B

123456789101112131415161718192021222324252627
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. },
  5. onLoad () {
  6. this.anim = this.node.getComponent(sp.Skeleton);
  7. this.anim.setCompleteListener(this.SpineEventCallback);
  8. },
  9. Run()
  10. {
  11. //this.anim.animation = 'run';// 要播放的动画名称【必填】
  12. //this.anim.loop = true;// 是否循环
  13. this.runAnim = this.anim.setAnimation(0, 'Run1', true);
  14. },
  15. Idel()
  16. {
  17. this.runAnim = this.anim.setAnimation(0, 'idle', true);
  18. },
  19. SpineEventCallback(trackEntry, loopCount)
  20. {
  21. if (trackEntry.animation.name === 'Run1') {
  22. cc.log('Run1结束')
  23. }
  24. }
  25. });