Charactor.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. cc.Class({
  2. extends: require("BaseCharactor"),
  3. properties: {
  4. jumpAudio: {
  5. default: [],
  6. type: [cc.AudioClip],
  7. },
  8. perfect: {
  9. default: null,
  10. type: cc.Node,
  11. serializable: true,
  12. },
  13. indicateLeft: {
  14. default: null,
  15. type: cc.Node,
  16. serializable: true,
  17. },
  18. indicateRight: {
  19. default: null,
  20. type: cc.Node,
  21. serializable: true,
  22. },
  23. },
  24. init()
  25. {
  26. this._super();
  27. this.indicateLeftAvatar = this.indicateLeft.getChildByName('Avatar');
  28. this.indicateLeftDistance = this.indicateLeft.getChildByName('Distance');
  29. this.indicateRightAvatar = this.indicateRight.getChildByName('Avatar');
  30. this.indicateRightDistance = this.indicateRight.getChildByName('Distance');
  31. },
  32. playJumpEffect()//over wirte
  33. {
  34. let audioClip = this.jumpAudio[this.pStatesSt.Combo];
  35. cc.audioEngine.playEffect(audioClip, 0, function () {});
  36. if(8==this.pStatesSt.Combo)
  37. {
  38. this.pStatesSt.Combo=0;
  39. if(!this.perfect.active)
  40. {
  41. this.perfect.active = true;
  42. }
  43. let anim = this.perfect.getComponent('cc.Animation');
  44. // 是动画组件cc.Animation组件实例来监听;
  45. anim.on("play", function()
  46. {
  47. // this.perfect.active = false;
  48. }.bind(this), this);
  49. anim.play();
  50. }
  51. this.pStatesSt.Combo++;
  52. },
  53. showIndicater(bLeft,distence)
  54. {
  55. if(bLeft)
  56. {
  57. this.indicateLeft.active = true;
  58. this.indicateRight.active = false;
  59. this.indicateLeftDistance.getComponent(cc.Label).string = distence;
  60. }
  61. else {
  62. this.indicateLeft.active = false;
  63. this.indicateRight.active = true;
  64. this.indicateRightDistance.getComponent(cc.Label).string = distence;
  65. }
  66. },
  67. hideIndicater()
  68. {
  69. this.indicateLeft.active = false;
  70. this.indicateRight.active = false;
  71. }
  72. });