Commit 5e4054e1 authored by liujiaxin's avatar liujiaxin

12ee

parent b1420a38
......@@ -315,7 +315,7 @@ cc.Class({
// an.active = true;
// const dragonDisplay = an.getComponent(dragonBones.ArmatureDisplay);
// dragonDisplay.playAnimation('normal', 0);
console.log('show animation', an.active);
// console.log('show animation', an.active);
reject()
} else {
resolve()
......@@ -383,7 +383,11 @@ cc.Class({
var dragonDisplay = this.logoCat.getComponent(dragonBones.ArmatureDisplay);
const state = dragonDisplay.playAnimation('begin', 0);
return new Promise((resolve,reject) => {
playAudioByUrl(this.data.begin_audio1, () => {
let a1 = this.data.begin_audio1;
if (this.begin_audio1) {
a1 = this.begin_audio1
}
playAudioByUrl(a1, () => {
console.log('game begin audio finish');
resolve()
})
......@@ -404,6 +408,10 @@ cc.Class({
dragonDisplay.playAnimation('normal', 0);
}
return new Promise((resolve,reject) => {
let a2 = this.data.begin_audio2;
if (this.begin_audio2) {
a2 = this.begin_audio2;
}
playAudioByUrl(this.data.begin_audio2, () => {
resolve()
})
......@@ -606,11 +614,21 @@ cc.Class({
}
}
},
prepareAudioClip(url, key) {
if (url) {
cc.assetManager.loadRemote(url, (err, audioClip) => {
if (audioClip) {
this[key] = audioClip;
}
});
}
},
addPreloadAudio() {
this._audioResList.push({ url: this.data.begin_audio1 });
this._audioResList.push({ url: this.data.begin_audio2 });
// this._audioResList.push({ url: this.data.begin_audio1 });
this.prepareAudioClip(this.data.begin_audio1, 'begin_audio1')
// this._audioResList.push({ url: this.data.begin_audio2 });
this.prepareAudioClip(this.data.begin_audio2, 'begin_audio2')
this._audioResList.push({ url: this.data.guide_audio });
this._audioResList.push({ url: this.data.playing_audio });
if (this.data.wrong_audio) {
......
......@@ -102,6 +102,14 @@ export function getDistance (start, end){
export function playAudioByUrl(audio_url, cb=null) {
if (audio_url) {
if ((audio_url instanceof cc.AudioClip) &&audio_url.constructor.name == 'cc_AudioClip') {
const audioId = cc.audioEngine.play(audio_url, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
} else {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
......@@ -109,7 +117,8 @@ export function playAudioByUrl(audio_url, cb=null) {
cb();
});
}
});
}); }
}
}
......
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