123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- const GameModule = require("./utils/GameModule");
- cc.Class({
- extends: cc.Component,
- properties: {
- bgm: {
- tooltip: '背景音乐',
- default: null,
- type: cc.AudioClip
- },
- buttonAudio: {
- tooltip: '按钮音效',
- default: null,
- type: cc.AudioClip
- },
- giftAudio: {
- tooltip: '获得奖励音效',
- default: null,
- type: cc.AudioClip
- },
- updateBuildingAudio: {
- tooltip: '升级建筑音效',
- default: null,
- type: cc.AudioClip
- },
- signSuccessAudio: {
- tooltip: '抢夺、进阶成功音效',
- default: null,
- type: cc.AudioClip
- },
- signFailAudio: {
- tooltip: '抢夺、进阶失败音效',
- default: null,
- type: cc.AudioClip
- },
- getCoinAudio: {
- tooltip: '收取金币音效',
- default: null,
- type: cc.AudioClip
- },
- volume: {
- tooltip: '总音量',
- default: 1,
- type: cc.Integer
- }
- },
- onLoad () {
- GameModule.audioMng = this;
- this.currentAudio = {};
- 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']);
- },
- /**
- * 播放按钮音效
- */
- playButton () {
- cc.audioEngine.play(this.buttonAudio, false, this.volume);
- },
- /**
- * 播放获得奖励音效
- */
- playGift () {
- cc.audioEngine.play(this.giftAudio, false, this.volume);
- },
- /**
- * 播放升级建筑音乐
- */
- playUpdateBuilding () {
- cc.audioEngine.play(this.updateBuildingAudio, false, this.volume);
- },
- /**
- * 播放抢夺、进阶成功音效
- */
- playSignSuccess () {
- cc.audioEngine.play(this.signSuccessAudio, false, this.volume);
- },
- /**
- * 播放抢夺、进阶失败音效
- */
- playSignFail () {
- cc.audioEngine.play(this.signFailAudio, false, this.volume);
- },
- /**
- * 播放收取金币音效
- */
- playGetcoin () {
- cc.audioEngine.play(this.getCoinAudio, false, this.volume);
- }
- // update (dt) {},
- });
|