新版本引擎添加了音频预加载功能,Jsb绑定了新的AudioEngine音频引擎,实测好用
/** * Created by Jerry on 15-8-25. */var GameAudio = GameAudio || { isOpenMusic : true,isOpenEffect : true,playMusic:function(filePath,isLoop){ if(!this.isOpenMusic) return; Jsb.AudioEngine.play2d(this.getAllPath(filePath),isLoop,1.0,Jsb.AudioEngine.getDefaultProfile()); },stopMusic:function(filePath){ Jsb.AudioEngine.uncache(this.getAllPath(filePath)); },playEffect:function(filePath){ if(!this.isOpenEffect) return; Jsb.AudioEngine.play2d(this.getAllPath(filePath),false,stopEffect:function(filePath){ Jsb.AudioEngine.uncache(this.getAllPath(filePath)); },stopAll:function(){ Jsb.AudioEngine.stopAll(); },getAllPath:function(filePath){ var path = ""; if(cc.sys.os == "androID"){ path = filePath + ".ogg"; }else{ path = filePath + ".mp3"; } return path; },getAudioEngine:function(){ return cc.audioEngine; },preloadSound:function(){ for (var i in res_sound){ if(cc.sys.os == "androID"){ Jsb.AudioEngine.preload(res_sound[i] + ".ogg",null); }else{ Jsb.AudioEngine.preload(res_sound[i] + ".mp3",null); } } }};PS:stopAll()在切场景更换背景音乐时使用,先停,再播。。。 总结
以上是内存溢出为你收集整理的cocos2d-x之3.8音频管理全部内容,希望文章能够帮你解决cocos2d-x之3.8音频管理所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)