Demostration.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. let gameConfig = require("GameConfig");
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. gameStates: {
  6. default: null,
  7. type: cc.Node,
  8. serializable: true,
  9. },
  10. videoplayer: {
  11. default: null,
  12. type: cc.Node,
  13. serializable: true,
  14. },
  15. videoController: {
  16. default: null,
  17. type: cc.Node,
  18. serializable: true,
  19. },
  20. title: {
  21. default: null,
  22. type: cc.Node,
  23. serializable: true,
  24. },
  25. },
  26. onLoad()
  27. {
  28. this.gStatesScp = this.gameStates.getComponent('GameStates');
  29. this.videoControllerScp = this.videoController.getComponent('SpriteVideoPlayer');
  30. this.audioControllerScp = this.node.getComponent('AudioController');
  31. this.audioNames = [
  32. '1、前绕肩',
  33. '2、后绕肩',
  34. '3、屈膝转体热身',
  35. '4、体前曲出拳',
  36. '5、拳击站架',
  37. '6、前直拳',
  38. '7、后直拳',
  39. '8、前后滑步',
  40. '9、前后滑步前直拳',
  41. '10、上步左右直拳',
  42. '11、侧闪',
  43. '12、前摆拳',
  44. '13、后勾拳',
  45. '14、前直后勾组合拳',
  46. '15、前摆后直组合拳',
  47. '16、直勾摆组合拳',
  48. '17、摇臂',
  49. '18、侧闪后直拳',
  50. '19、交替出拳',
  51. '20、右侧肩部拉伸',
  52. '21、左侧肩部拉伸',
  53. '22、左臂拉伸',
  54. '23、右臂拉伸',
  55. '24、最后一个动作,坚持就是胜利'
  56. ];
  57. },
  58. play(callback)
  59. {
  60. let self = this;
  61. this.gStatesScp.curretState = this.gStatesScp.demonstration;
  62. this.round = gameConfig.round[this.gStatesScp.currentRound];
  63. this.videoControllerScp.play(this.videoplayer,this.gStatesScp.currentRound,self,this.videoCompleted);
  64. this.title.getComponent(cc.Label).string = '动作预览: '+this.round.name;
  65. this.playAudioHint(callback);
  66. },
  67. videoCompleted(self)
  68. {
  69. if(self.gStatesScp.curretState == self.gStatesScp.demonstration)
  70. {
  71. self.videoControllerScp.play(self.videoplayer,self.gStatesScp.currentRound,self,self.videoCompleted);
  72. }
  73. },
  74. playAudioHint(callback)
  75. {
  76. let self = this;
  77. let demonstrationAudios = [
  78. 'Audios/Game/Others/11、休息结束,下一个动作',
  79. 'Audios/Game/Names/'+this.audioNames[this.gStatesScp.currentRound],
  80. // 'Audios/Game/Others/1、一组',
  81. ];
  82. demonstrationAudios.push(this.round.second);
  83. this.audioControllerScp.playAudioBySequence(demonstrationAudios,function () {
  84. // console.log('111111')
  85. self.scheduleOnce(function () {
  86. self.gStatesScp.curretState = self.gStatesScp.countDown;
  87. // self.main.active = true;
  88. cc.tween(this.node)
  89. .by(0.5, { position: cc.v2(-this.node.width, 0) })
  90. .call(() => {
  91. self.node.x = 0;
  92. // self.node.active = false;
  93. self.node.opacity = 0;
  94. })
  95. .start();
  96. self.videoControllerScp.stop();
  97. callback();
  98. },1);
  99. });
  100. }
  101. });