ArrowAnimation.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var animationType = cc.Enum({
  2. UpAndDown: -1,
  3. //手指滑动
  4. FingerSliding: -1,
  5. });
  6. cc.Class({
  7. extends: cc.Component,
  8. properties: {
  9. //类型
  10. animationEnum: {
  11. default: animationType.UpAndDown,
  12. type: cc.Enum(animationType),
  13. },
  14. },
  15. random(max, min) {
  16. return Math.floor(Math.random() * (max - min + 1) + min);
  17. },
  18. start() {
  19. //初始化任务
  20. switch (this.animationEnum) {
  21. case animationType.UpAndDown:
  22. this.node.stopAllActions();
  23. var s = cc.sequence(cc.moveBy(0.5, 0, 20), cc.moveBy(0.5, 0, -20));
  24. var repeat = cc.repeatForever(s);
  25. this.node.runAction(repeat);
  26. break;
  27. case animationType.FingerSliding:
  28. this.node.stopAllActions();
  29. var s = cc.sequence(cc.moveBy(0, -200, 130),cc.moveBy(1, 200, -130),cc.delayTime(1));
  30. var repeat = cc.repeatForever(s);
  31. this.node.runAction(repeat);
  32. break;
  33. }
  34. },
  35. });