Commit 9ba6a5ca authored by wangxin's avatar wangxin

Update op_sound.js

parent e5e6af37
...@@ -34,18 +34,21 @@ cc.Class({ ...@@ -34,18 +34,21 @@ cc.Class({
_soundUrl: "", // 音频文件地址 _soundUrl: "", // 音频文件地址
_opPic: null, _opPic: null,
_isRight: false, _isRight: false,
_isPlaying: false,
}, },
/** /**
* 播放声音 * 播放声音
*/ */
play() { play() {
if (this._soundUrl != "") { if (this._soundUrl != "" && !this._isPlaying) {
this._isPlaying = true;
cc.assetManager.loadRemote(this._soundUrl, (err, audioClip) => { cc.assetManager.loadRemote(this._soundUrl, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8); const audioId = cc.audioEngine.play(audioClip, false, 0.8);
this.iconSound.getComponent(cc.Animation).play("icon_sound_play"); this.iconSound.getComponent(cc.Animation).play("icon_sound_play");
cc.audioEngine.setFinishCallback(audioId, () => { cc.audioEngine.setFinishCallback(audioId, () => {
this.iconSound.getComponent(cc.Animation).play("icon_sound_finish"); this.iconSound.getComponent(cc.Animation).play("icon_sound_finish");
this._isPlaying = false;
}); });
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment