Charactor.js 1007 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. cc.Class({
  2. extends: require("BaseCharactor"),
  3. properties: {
  4. },
  5. onLoad () {
  6. this.armatureDisplay = this.node.getComponent(dragonBones.ArmatureDisplay);
  7. this.armature = this.armatureDisplay.armature();
  8. //添加动画事件监听
  9. this.armatureDisplay.addEventListener(dragonBones.EventObject.COMPLETE, this.animationEventHandler, this);
  10. },
  11. start () {
  12. },
  13. attack(bLeft){
  14. if(bLeft)
  15. {
  16. this.armature.animation.play("attack",1);
  17. }
  18. else
  19. {
  20. this.armature.animation.play("attack",1);
  21. }
  22. },
  23. animationEventHandler(event) {
  24. if (event.type === dragonBones.EventObject.COMPLETE) {
  25. if (event.animationState.name === "attack") {
  26. console.log("attack 动作播放完毕!!!");
  27. //TODO:
  28. this.armature.animation.play("idle",-1);
  29. }
  30. }
  31. }
  32. // update (dt) {},
  33. });