Commit 874dc9a4 authored by Tt's avatar Tt

处理题干音频乱播问题

parent 7bcf7521
{"ver":"1.1.2","uuid":"c35bb2f6-f24a-4850-ae44-643f2fdc7541","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}} {
\ No newline at end of file "ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
...@@ -16,6 +16,8 @@ export default class NewClass extends cc.Component { ...@@ -16,6 +16,8 @@ export default class NewClass extends cc.Component {
onLoad() { onLoad() {
pg.view.touchOn(this.node, this.onTouchLaba, this); pg.view.touchOn(this.node, this.onTouchLaba, this);
pg.event.on("play_stem", () => { pg.event.on("play_stem", () => {
cc.audioEngine.stopAllEffects();
this.playing = false;
this.onTouchLaba().then(() => { this.onTouchLaba().then(() => {
pg.event.emit("game_start_loop") pg.event.emit("game_start_loop")
}) })
...@@ -27,16 +29,21 @@ export default class NewClass extends cc.Component { ...@@ -27,16 +29,21 @@ export default class NewClass extends cc.Component {
} }
onTouchLaba() { onTouchLaba() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.playing) return;
this.playing = true;
this.showAni(); this.showAni();
pg.audio.playAudioByUrl(Game.getIns().nowAudio).then(() => { pg.audio.playAudioByUrl(Game.getIns().nowAudio).then(() => {
this.playing = false;
this.stopAni(); this.stopAni();
resolve(''); resolve('');
}) })
}); });
} }
private playing: boolean;
private count: number; private count: number;
showAni() { showAni() {
this.count = 0; this.count = 0;
this.labaAni();
this.schedule(this.labaAni, 0.1); this.schedule(this.labaAni, 0.1);
} }
stopAni() { stopAni() {
......
...@@ -437,7 +437,7 @@ let pg = { ...@@ -437,7 +437,7 @@ let pg = {
cc.assetManager.loadRemote(audio_url, (err, audioClip: any) => { cc.assetManager.loadRemote(audio_url, (err, audioClip: any) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8); const audioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(audioId, () => { cc.audioEngine.setFinishCallback(audioId, () => {
resolve(audioClip); resolve(audioId);
}); });
}); });
}); });
......
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