| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- window.soundM = {
- sound : null
- }
- cc.Class({
- extends: cc.Component,
- properties: {
- Sound_BGM: {
- default: null,
- type: cc.AudioClip
- },
- StartGame_Clip: {
- default: null,
- type: cc.AudioClip
- },
- Login_Clip: {
- default: null,
- type: cc.AudioClip
- },
- StartToPlayTutorial_Clip:{
- default: null,
- type: cc.AudioClip
- },
- Tutorial_Clip:{
- default: null,
- type: cc.AudioClip
- },
- Settlement_Clip: {
- default: null,
- type: cc.AudioClip
- },
- Close_Clip: {
- default: null,
- type: cc.AudioClip
- },
- Score_Clip: {
- default: null,
- type: cc.AudioClip
- },
- },
- start () {
- this.playScoremin = 0;
- this.playScoreNum = 0;
- this.playScoreMax = 6;
- this.schedule(function(){
- cc.sys.garbageCollect();
- },10);
- soundM.sound = this;
- this.initBG();
- cc.game.on(cc.game.EVENT_HIDE, function(){
- console.log("游戏进入后台");
- cc.audioEngine.setMusicVolume(0);
- },this);
- cc.game.on(cc.game.EVENT_SHOW, function(){
- console.log("重新返回游戏");
- cc.audioEngine.setMusicVolume(0.5);
- },this);
- },
- initBG : function(){
- cc.audioEngine.playMusic(this.Sound_BGM,true);
- cc.audioEngine.setMusicVolume(0.5);
- },
- startToPlayTutorial: function () {
- this.StartToPlayTutorial_ClipID = cc.audioEngine.play(this.StartToPlayTutorial_Clip,false,1);
- return this.StartToPlayTutorial_ClipID;
- },
- playTutorial: function () {
- this.Tutorial_ClipID = cc.audioEngine.play(this.Tutorial_Clip,false,1);
- return this.Tutorial_ClipID;
- },
- playScore: function () {
- if (this.playScoreNum <= this.playScoreMax) {
- this.playScoreNum++;
- }else{
- this.Score_ClipID = cc.audioEngine.play(this.Score_Clip,false,0.2);
- this.playScoreNum = this.playScoremin;
- }
- return this.Score_ClipID;
- },
- playLogin : function () {
- this.Login_ClipID = cc.audioEngine.play(this.Login_Clip,false,1);
- return this.Login_ClipID;
- },
- playStartGame : function () {
- this.StartGame_ClipID = cc.audioEngine.play(this.StartGame_Clip,false,1);
- return this.StartGame_ClipID;
- },
- playSettlement : function () {
- this.Settlement_ClipID = cc.audioEngine.play(this.Settlement_Clip,false,1);
- return this.Settlement_ClipID;
- },
- playClose : function () {
- this.Close_ClipID = cc.audioEngine.play(this.Close_Clip,false,1);
- return this.Close_ClipID;
- },
- stopAll : function(){
- // this.unschedule(this.findWorkCallback);
- cc.audioEngine.stopAll();
- },
- stopMusic : function(){
- // this.unschedule(this.findWorkCallback);
- cc.audioEngine.stopMusic();
- },
- stop : function(ID){
- // this.unschedule(this.findWorkCallback);
- cc.audioEngine.stop(ID);
- },
- stopAllSoundEffect : function(){
- cc.audioEngine.stop(this.StartToPlayTutorial_ClipID);
- cc.audioEngine.stop(this.Tutorial_ClipID);
- cc.audioEngine.stop(this.Login_ClipID);
- cc.audioEngine.stop(this.StartGame_ClipID);
- cc.audioEngine.stop(this.Settlement_ClipID);
- cc.audioEngine.stop(this.Close_ClipID);
- }
- });
|