123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- 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) {},
- });
|