const GameModule = require("../utils/GameModule"); cc.Class({ extends: cc.Component, properties: { bgm: { tooltip: '背景音乐', default: null, type: cc.AudioClip }, buttonClickAudio: { tooltip: '普通按钮点击音效', default: null, type: cc.AudioClip }, getAwardAudio: { tooltip: '获得技能、奖励音效', default: null, type: cc.AudioClip }, updateBuildingAudio: { tooltip: '升级或解锁建筑,购买明星音效', default: null, type: cc.AudioClip }, clickCatAudio: { tooltip: '点击招财猫音效', default: null, type: cc.AudioClip }, getDrawAudio: { tooltip: '抽奖音效', default: null, type: cc.AudioClip }, getStarAudio: { tooltip: '获得明星音效', default: null, type: cc.AudioClip }, volume: { tooltip: '总音量', default: 1, type: cc.Integer } }, onLoad () { GameModule.audioMng = this; this.currentAudio = {}; this.stopAll(); this.playBgm(); }, /** * 暂停所有音效 */ stopAll () { cc.audioEngine.stopAll(); }, /** * 播放背景音乐 */ playBgm () { this.currentAudio['bgm'] = cc.audioEngine.play(this.bgm, true, this.volume); }, /** * 暂停播放背景音乐 */ stopBgm () { cc.audioEngine.stop(this.currentAudio['bgm']); }, /** * 播放按钮音效 */ playClickButton () { cc.audioEngine.play(this.buttonClickAudio, false, this.volume); }, /** * 播放获得奖励音效 */ playGetAward () { cc.audioEngine.play(this.getAwardAudio, false, this.volume); }, /** * 播放升级建筑音效 */ playUpdateBuilding () { cc.audioEngine.play(this.updateBuildingAudio, false, this.volume); }, /** * 点击招财猫 */ playClickCat () { cc.audioEngine.play(this.clickCatAudio, false, this.volume); }, /** * 抽奖音效 */ playGetDraw () { cc.audioEngine.play(this.getDrawAudio, false, this.volume); }, /** * 获取到明星音效 */ playGetStar () { cc.audioEngine.play(this.getStarAudio, false, this.volume); }, // update (dt) {}, });