StartGame.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Learn cc.Class:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/class.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. cc.Class({
  8. extends: cc.Component,
  9. properties: {
  10. toNext:cc.Node,
  11. personShow:cc.Node,
  12. showTime:0,
  13. audio: {
  14. default: null,
  15. type: cc.AudioClip
  16. },
  17. // hoooAudio:{
  18. // default: null,
  19. // type: cc.AudioClip
  20. // },
  21. bgMusic:{
  22. default: null,
  23. type: cc.AudioClip
  24. }
  25. },
  26. startClick(){
  27. // this.current = cc.audioEngine.play(this.audio, true, 1);
  28. let bgMusicAll = cc.audioEngine.playMusic(this.bgMusic, true);
  29. cc.audioEngine.setVolume(bgMusicAll, 0.5);
  30. let audioId = cc.audioEngine.playEffect(this.audio, false);
  31. cc.audioEngine.setVolume(audioId, 1);
  32. cc.director.loadScene("sence_game");
  33. },
  34. onDownLoad(e){
  35. // $('#btn').on('touchstart', function (e) {
  36. let audioId = cc.audioEngine.playEffect(this.audio, false);
  37. cc.audioEngine.setVolume(audioId, 1);
  38. window.playableSDK.sendEvent('clickDownloadBar', {
  39. section: 'section2',
  40. area: 'area3'
  41. });
  42. window.playableSDK.openAppStore()
  43. // })
  44. },
  45. // LIFE-CYCLE CALLBACKS:
  46. onLoad () {
  47. },
  48. start () {
  49. // 场景文本框为 显示5
  50. this.showTime = 0;
  51. if (this.showTime >= 0) {
  52. this.schedule(function () { // 计时器将每隔 1s 执行一次。
  53. this.textChane();
  54. if(this.showTime==1){
  55. // let audioId = cc.audioEngine.playEffect(this.hoooAudio, false);
  56. // cc.audioEngine.setVolume(audioId, 1);
  57. this.personShow.active = true
  58. }
  59. }, 1);
  60. }
  61. },
  62. textChane(){
  63. this.showTime = this.showTime + 1;
  64. }
  65. // update (dt) {},
  66. });