FlyCat.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { GameNotificationKey } from "../utils/GameEnum";
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. catNode: cc.Node,
  6. catSkeleton: sp.Skeleton,
  7. },
  8. onLoad() {
  9. },
  10. fly(startPosition, endPosition) {
  11. this.catNode.setPosition(startPosition);
  12. this.catNode.setScale(0.1);
  13. let moveTo = cc.moveTo(0.4, 0, 0);
  14. let scaleTo = cc.scaleTo(0.4, 1, 1);
  15. this.catNode.runAction(cc.spawn(moveTo, scaleTo));
  16. this.catSkeleton.setAnimation(0, 'hit2', false);
  17. this.catSkeleton.setCompleteListener(() => {
  18. this.catSkeleton.setAnimation(0, 'fly', true);
  19. let move = cc.moveTo(0.5, endPosition.x, endPosition.y);
  20. let scale = cc.scaleTo(0.5, 0.1, 0.1);
  21. let a = cc.spawn(move, scale);
  22. let finish = cc.callFunc(() => {
  23. GameEvent.fire(GameNotificationKey.afterCatFly);
  24. this.node.destroy();
  25. }, this);
  26. let s = cc.sequence(a, finish)
  27. this.catNode.runAction(s);
  28. });
  29. },
  30. start() {
  31. },
  32. });