Charactor.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. countingJumpDistance(hurdrailStartPX,gameConfig){
  33. return hurdrailStartPX + gameConfig.handrailLength;
  34. },
  35. playJumpEffect()//over wirte
  36. {
  37. let audioClip = this.jumpAudio[this.pStatesSt.Combo];
  38. cc.audioEngine.playEffect(audioClip, 0, function () {});
  39. if(8==this.pStatesSt.Combo)
  40. {
  41. this.pStatesSt.Combo=0;
  42. if(!this.perfect.active)
  43. {
  44. this.perfect.active = true;
  45. }
  46. let anim = this.perfect.getComponent('cc.Animation');
  47. // 是动画组件cc.Animation组件实例来监听;
  48. anim.on("play", function()
  49. {
  50. // this.perfect.active = false;
  51. }.bind(this), this);
  52. anim.play();
  53. }
  54. this.pStatesSt.Combo++;
  55. },
  56. showIndicater(bLeft,distence)
  57. {
  58. if(bLeft)
  59. {
  60. this.indicateLeft.active = true;
  61. this.indicateRight.active = false;
  62. this.indicateLeftDistance.getComponent(cc.Label).string = distence;
  63. }
  64. else {
  65. this.indicateLeft.active = false;
  66. this.indicateRight.active = true;
  67. this.indicateRightDistance.getComponent(cc.Label).string = distence;
  68. }
  69. },
  70. hideIndicater()
  71. {
  72. this.indicateLeft.active = false;
  73. this.indicateRight.active = false;
  74. }
  75. });