12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- // Learn cc.Class:
- // - https://docs.cocos.com/creator/manual/en/scripting/class.html
- // Learn Attribute:
- // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
- var UIHelper = require("UIHelper");
- var Global = require("Global");
- cc.Class({
- extends: cc.Component,
- statics: {
- LG_PATH_SC: "LB-Roman/",
- bgmAudioID:-1,
- btnEff: ["button"],
- rewardEff: ["Level01","Level02","Level03","Level04","Level05","Level08","Level09","Level10","Level11","Level12","Level13","Level14","Level15"],
- init() {
- var self = this;
- this.rewardAudio = [];
- // UIHelper.loadRes("sounds/SGLB/Level01", cc.AudioClip, function(audioClip){
- // self.rewardAudio[1] = audioClip;
- // });
- for(let i = 0; i < self.rewardEff.length; ++i) {
- UIHelper.loadRes("sounds/LB-Public/"+self.rewardEff[i], cc.AudioClip, function(audioClip){
- self.rewardAudio[i] = audioClip;
- });
- }
-
- UIHelper.loadRes("sounds/LB-Roman/freestart", cc.AudioClip, function(audioClip){
- self.freeAudio = audioClip;
- });
- },
- playBackMusic(kName) {
- var path = this.LG_PATH_SC + kName;
- if (cc.vv && cc.vv.audioMgr) {
- this.bgmAudioID = cc.vv.audioMgr.playBGM(path);
- }
- },
- pauseBackMusic() {
- if (cc.vv && cc.vv.audioMgr) {
- cc.vv.audioMgr.pauseBackMusic();
- }
- },
- resumeBackMusic() {
- if (cc.vv && cc.vv.audioMgr) {
- cc.vv.audioMgr.resumeBackMusic();
- }
- },
- stopBackMusic() {
- if (cc.vv && cc.vv.audioMgr) {
- cc.vv.audioMgr.stopBackMusic();
- }
- },
- playEffect(kName, preload) {
- var path = this.LG_PATH_SC + kName;
- if (cc.vv && cc.vv.audioMgr) {
- cc.vv.audioMgr.playSFX(path);
- }
- },
- playRewardEffect(id) {
- let audio = this.rewardAudio[id];
- if(audio) {
- return cc.audioEngine.play(audio, false, cc.vv.audioMgr.sfxVolume);
- }
- return -1;
- },
- playFreeEffect() {
- if(this.freeAudio) {
- return cc.audioEngine.play(this.freeAudio, false, cc.vv.audioMgr.sfxVolume);
- }
- return -1;
- },
- stopEffectByID(audioID) {
- if (audioID >= 0 && cc.vv && cc.vv.audioMgr) {
- cc.vv.audioMgr.stopSFX(audioID);
- }
- },
- playEffectArr(kNameArr) {
- var kName = kNameArr[0];
- if (kNameArr.length > 1) {
- var index = Math.floor(Math.random()*1000 % kNameArr.length);
- kName = kNameArr[index];
- }
- this.playEffect(kName);
- },
- },
- });
|