Combo.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. perfect: {
  5. default: null,
  6. type: cc.Node,
  7. serializable: true,
  8. },
  9. combo: {
  10. default: null,
  11. type: cc.Node,
  12. serializable: true,
  13. },
  14. x: {
  15. default: null,
  16. type: cc.Node,
  17. serializable: true,
  18. },
  19. num: {
  20. default: null,
  21. type: cc.Node,
  22. serializable: true,
  23. },
  24. hitAudio: {
  25. default: null,
  26. type: cc.AudioClip,
  27. serializable: true,
  28. },
  29. perfectAudio: {
  30. default: null,
  31. type: cc.AudioClip,
  32. serializable: true,
  33. },
  34. counting:0,
  35. },
  36. onLoad()
  37. {
  38. this.centerPosition = this.node.position;
  39. this.tween = cc.tween;
  40. },
  41. triggleCombo()
  42. {
  43. this.node.stopAllActions();
  44. this.node.position = this.centerPosition;
  45. this.node.opacity = 255;
  46. this.node.scale = 1;
  47. this.unschedule(this.unTriggleCombo);
  48. this.scheduleOnce(this.unTriggleCombo,2);
  49. if(this.counting == 10)
  50. {
  51. this.counting = 0;
  52. this.combo.active = false;
  53. this.x.active = false;
  54. this.num.active = false;
  55. this.perfect.active = true;
  56. cc.audioEngine.play(this.perfectAudio, false, 1);
  57. this.tween(this.node)
  58. .parallel(
  59. this.tween().to(1, { opacity: 0 }),
  60. this.tween().by(1, { scale: 1.2 }),
  61. this.tween().by(1, { position: cc.v2(0, 100) })
  62. )
  63. .start();
  64. return;
  65. }
  66. this.combo.active = true;
  67. this.x.active = true;
  68. this.num.active = true;
  69. this.perfect.active = false;
  70. this.counting++;
  71. this.num.getComponent(cc.Label).string = this.counting.toString();
  72. cc.audioEngine.play(this.hitAudio, false, 1);
  73. this.tween(this.node)
  74. .by(0.1, { position: cc.v2(0, 100) })
  75. .parallel(
  76. this.tween().to(1, { opacity: 0 }),
  77. this.tween().by(1, { position: cc.v2(0, 100) })
  78. )
  79. .start()
  80. },
  81. unTriggleCombo()
  82. {
  83. this.counting = 0;
  84. this.combo.active = false;
  85. this.x.active = false;
  86. this.num.active = false;
  87. this.perfect.active = false;
  88. },
  89. });