Charactor.js 836 B

123456789101112131415161718192021222324252627282930313233
  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. },
  15. animationEventHandler(event) {
  16. if (event.type === dragonBones.EventObject.COMPLETE) {
  17. if (event.animationState.name === "attack") {
  18. console.log("attack 动作播放完毕!!!");
  19. //TODO:
  20. this.armature.animation.play("idle",-1);
  21. }
  22. }
  23. }
  24. // update (dt) {},
  25. });