bgm.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. bgm: {
  14. default: null,
  15. type: cc.AudioClip
  16. },
  17. a: {
  18. default: null,
  19. type: cc.AudioClip
  20. },
  21. hei: {
  22. default: null,
  23. type: cc.AudioClip
  24. },
  25. ha: {
  26. default: null,
  27. type: cc.AudioClip
  28. },
  29. imwin: {
  30. default: null,
  31. type: cc.AudioClip
  32. },
  33. kuaidaozhongdian: {
  34. default: null,
  35. type: cc.AudioClip
  36. },
  37. luoshui: {
  38. default: null,
  39. type: cc.AudioClip
  40. },
  41. wohuihuilaide: {
  42. default: null,
  43. type: cc.AudioClip
  44. },
  45. zhecibusuan: {
  46. default: null,
  47. type: cc.AudioClip
  48. },
  49. },
  50. // LIFE-CYCLE CALLBACKS:
  51. onLoad () {
  52. app.bgm = this;
  53. },
  54. start () {
  55. this.myMusic = null;
  56. },
  57. stop : function(){
  58. cc.audioEngine.stopMusic();
  59. },
  60. play : function () {
  61. if (this.myMusic != null) {
  62. this.stop();
  63. }
  64. this.myMusic = cc.audioEngine.playMusic(this.bgm,true);
  65. },
  66. //掉下去了
  67. playa : function () {
  68. cc.audioEngine.play(this.a,false,1);
  69. },
  70. //两步
  71. playhei : function () {
  72. cc.audioEngine.play(this.hei,false,0.5);
  73. },
  74. // 一步
  75. playha : function () {
  76. cc.audioEngine.play(this.ha,false,0.5);
  77. },
  78. playimwin : function () {
  79. cc.audioEngine.play(this.imwin,false,1);
  80. setTimeout(function () {
  81. this.stop();
  82. }.bind(this),700)
  83. },
  84. playkuaidaozhongdian : function () {
  85. cc.audioEngine.play(this.kuaidaozhongdian,false,1);
  86. },
  87. playluoshui : function () {
  88. cc.audioEngine.play(this.luoshui,false,1);
  89. },
  90. playwohuihuilaide : function () {
  91. cc.audioEngine.play(this.wohuihuilaide,false,1);
  92. },
  93. playzhecibusuan : function () {
  94. cc.audioEngine.play(this.zhecibusuan,false,1);
  95. setTimeout(function () {
  96. this.stop();
  97. }.bind(this),700)
  98. },
  99. // update (dt) {},
  100. });