版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hj960511/article/details/82382724
白鹭引擎
版本:5.2.8
描述:开启和关闭音频的代码实例
声明对象
private bgm:egret.Sound;//放屁声音
private bgmStop:egret.SoundChannel;//取消放屁
开启音频
//播放声音
this.bgm = new egret.Sound();
this.bgm.addEventListener(egret.Event.COMPLETE, function loadOver(event:egret.Event) {
this.bgmStop = this.bgm.play();
}, this);
this.bgm.addEventListener(egret.IOErrorEvent.IO_ERROR, function loadError(event:egret.IOErrorEvent) {
console.log("loaded error!");
}, this);
this.bgm.load("resource/sound/bgm.mp3");
关闭音频
this.bgmStop.stop();