AniPrefab.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. },
  5. //onLoad Init
  6. Init:function(Hook){
  7. this.m_Hook = Hook;
  8. this.m_DBAni = this.node.getComponent(dragonBones.ArmatureDisplay)
  9. //添加动画监听
  10. this.m_DBAni.addEventListener(dragonBones.EventObject.COMPLETE, this.AniFinish, this);
  11. },
  12. PlayAni:function(AniName, Cnt){
  13. this.m_PlayCnt = Cnt;
  14. this.m_DBAni.armatureName = AniName;
  15. this.m_DBAni.playAnimation('newAnimation', Cnt);
  16. },
  17. AniFinish:function (event) {
  18. if(event == null) return
  19. if( event.type == dragonBones.EventObject.COMPLETE){
  20. if(this.m_PlayCnt == 1) this.m_Hook.AniFinish();
  21. }
  22. },
  23. PlayAni2:function(ArmatureName, AnimationName, Cnt){
  24. this.m_PlayCnt = Cnt;
  25. this.m_DBAni.buildArmature(ArmatureName);
  26. this.m_DBAni.armatureName = ArmatureName;
  27. if(!this.m_DBAni.node.hasEventListener(dragonBones.EventObject.COMPLETE, true)) {
  28. this.m_DBAni.addEventListener(dragonBones.EventObject.COMPLETE, this.AniFinish, this);
  29. }
  30. this.m_DBAni.playAnimation(AnimationName, Cnt);
  31. },
  32. PlayAniXiPai:function(AniName, Cnt, Name){
  33. this.m_PlayCnt = Cnt;
  34. this.m_DBAni._armatureName = AniName
  35. this.m_DBAni.playAnimation(Name, Cnt);
  36. },
  37. // update (dt) {},
  38. });