Commit 67230368 authored by 李维's avatar 李维

Dev test

parent 30c8eefc
...@@ -140,7 +140,9 @@ export default class Cartoon { ...@@ -140,7 +140,9 @@ export default class Cartoon {
// Audio // Audio
playAudio(audio_url, cb = null) { playAudio(audio_url, cb = null) {
return new Promise((res, rej) => { // return new Promise((res, rej) => {
// })
if (audio_url) { if (audio_url) {
var urlreg=/^(?=^.{3,255}$)(http(s)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*([\?&]\w+=\w*)*$/ var urlreg=/^(?=^.{3,255}$)(http(s)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*([\?&]\w+=\w*)*$/
if(urlreg.test(audio_url)) { if(urlreg.test(audio_url)) {
...@@ -155,7 +157,7 @@ export default class Cartoon { ...@@ -155,7 +157,7 @@ export default class Cartoon {
cb(); cb();
}); });
} }
res(audio) // res(audio)
}); });
} else { } else {
const audioNode = cc.find('Canvas/res/audio').getChildByName(audio_url).getComponent(cc.AudioSource); const audioNode = cc.find('Canvas/res/audio').getChildByName(audio_url).getComponent(cc.AudioSource);
...@@ -167,10 +169,9 @@ export default class Cartoon { ...@@ -167,10 +169,9 @@ export default class Cartoon {
cb(); cb();
}); });
} }
res(audio) // res(audio)
} }
} }
})
} }
stopAllAudio(exceptUrls = []) { stopAllAudio(exceptUrls = []) {
......
...@@ -110,11 +110,12 @@ export default class GameLogic { ...@@ -110,11 +110,12 @@ export default class GameLogic {
initBGMusic() { initBGMusic() {
if(this.g_formData.bgMusic) { if(this.g_formData.bgMusic) {
this.g_cartoon.playAudio(this.g_formData.bgMusic).then(bgMusic => { this.g_cartoon.playAudio(this.g_formData.bgMusic)
console.log(bgMusic) // .then(bgMusic => {
bgMusic.isLoop = true; // console.log(bgMusic)
bgMusic.setVolume(0.3) // bgMusic.isLoop = true;
}) // bgMusic.setVolume(0.3)
// })
} }
} }
......
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