1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- 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 () {
- 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']);
- },
- /**
- * 播放按钮音效
- */
- playButton () {
- cc.audioEngine.play(this.buttonAudio, false, this.volume);
- }
- // update (dt) {},
- });
|