FlyCat.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. catNode: cc.Node,
  5. catSkeleton: sp.Skeleton,
  6. },
  7. onLoad() {
  8. this.catNode.on(cc.Node.EventType.TOUCH_START, () => {
  9. this.catSkeleton.setAnimation(0, 'hit', false);
  10. this.catSkeleton.setCompleteListener(() => {
  11. this.catSkeleton.setAnimation(0, 'stand', true);
  12. });
  13. }, this);
  14. },
  15. fly(startPosition) {
  16. this.catNode.setPosition(startPosition);
  17. this.catNode.setScale(0.1);
  18. let moveTo = cc.moveTo(0.4, 0, 0);
  19. let scaleTo = cc.scaleTo(0.4, 1, 1);
  20. this.catNode.runAction(cc.spawn(moveTo, scaleTo));
  21. this.catSkeleton.setAnimation(0, 'hit2', false);
  22. this.catSkeleton.setCompleteListener(() => {
  23. this.catSkeleton.setAnimation(0, 'fly', true);
  24. let move = cc.moveTo(0.5, 293, 0);
  25. let scale = cc.scaleTo(0.5, 0.1, 0.1);
  26. let a = cc.spawn(move, scale);
  27. let finish = cc.callFunc(() => {
  28. this.node.destroy();
  29. }, this);
  30. let s = cc.sequence(a, finish)
  31. this.catNode.runAction(s);
  32. });
  33. },
  34. start() {
  35. },
  36. });