cc.Class({ extends: cc.Component, properties: { bgm: { default: null, url: cc.AudioClip }, bgmBingo: { default: null, url: cc.AudioClip }, buttonAudio: { default: null, url: cc.AudioClip }, loseAudio: { default: null, url: cc.AudioClip }, enter1Audio: { default: null, url: cc.AudioClip }, enter2Audio: { default: null, url: cc.AudioClip }, enter3Audio: { default: null, url: cc.AudioClip }, shootAudio: { default: null, url: cc.AudioClip }, goldAudio: { default: null, url: cc.AudioClip }, volume: 1 }, onLoad () { this.currentAudio = {}; }, /** * 暂停所有音效 */ stopAll () { cc.audioEngine.stopAll(); }, /** * 播放背景音乐 */ playBgm () { this.currentAudio['bgm'] = cc.audioEngine.play(this.bgm, true, this.volume); }, /** * 暂停播放背景音乐 */ stopBgm () { cc.audioEngine.stop(this.currentAudio['bgm']); }, /** * 播放华彩模式音乐 */ playBgmBingo () { this.stopBgm(); this.currentAudio['bgmBingo'] = cc.audioEngine.play(this.bgmBingo, true, this.volume); }, /** * 暂停播放华彩模式音乐 */ stopBgmBingo () { cc.audioEngine.stop(this.currentAudio['bgmBingo']); }, stopAll () { cc.audioEngine.stopAll(); }, /** * 播放失败音乐 */ playLose () { this.stopBgm(); cc.audioEngine.play(this.loseAudio, false, this.volume); }, /** * 播放按钮音效 */ playButton () { cc.audioEngine.play(this.buttonAudio, false, this.volume); }, /** * 播放插中瓶子音效 */ playEnter () { let ran = Math.floor(cc.random0To1() * 3); let enterMap = [this.enter1Audio, this.enter2Audio, this.enter3Audio] cc.audioEngine.play(enterMap[ran], false, this.volume); }, /** * 播放获取金币音效 */ playGetGold () { cc.audioEngine.play(this.goldAudio, false, this.volume); }, /** * 播放箭矢发射音效 */ playShoot () { cc.audioEngine.play(this.shootAudio, false, this.volume); }, _playSFX: function(clip) { cc.audioEngine.playEffect( clip, false ); }, // update (dt) {}, });