Charactor.js 804 B

1234567891011121314151617181920212223242526272829303132
  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. });