Commit e0159138 authored by yu's avatar yu

1

parent fa385dae
{
"ver": "2.0.1",
"uuid": "4f07dbcf-4a58-4d34-a598-a86b0b06712d",
"downloadMode": 0,
"duration": 29.962449,
"subMetas": {}
}
\ No newline at end of file
......@@ -2,6 +2,6 @@
"ver": "2.0.1",
"uuid": "d2584e3d-ee16-4da1-a5a4-66b3ecd5bb2a",
"downloadMode": 0,
"duration": 9.833563,
"duration": 4.032,
"subMetas": {}
}
\ No newline at end of file
......@@ -67,6 +67,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initData();
this.initView();
this.initEvent();
this.playLocalBgmAudio();
}
protected onDestroy(): void {
pg.event.clear();
......@@ -165,13 +166,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
let ques = Game.getIns().getList();
ques.forEach((q) => {
if(q.type == "img"){
if (q.type == "img") {
let itemBox = cc.instantiate(this.card_boximg);
itemBox.parent = this.layout_box;
pg.view.setNetImg( cc.find("img", itemBox), q.image, { w: 190, h: 140 });
pg.view.setNetImg(cc.find("img", itemBox), q.image, { w: 190, h: 140 });
itemBox.data = q;
this.wordItams.push(itemBox);
}else{
} else {
let itemBox = cc.instantiate(this.card_box);
itemBox.parent = this.layout_box;
cc.find("desc", itemBox).getComponent(cc.Label).string = q.text;
......@@ -405,7 +406,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.gameOver();
return;
}
if (this.gameCount < 9 && this.playCount) {
if (this.gameCount < 3 && this.playCount) {
this.playCount = false;
this.playLocalAudio("count").then(() => {
this.playCount = true;
......@@ -447,12 +448,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
playLocalAudio(audioName) {
let noStop = audioName == "count";
if (!noStop) this.stopBgmAdudio();
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => { resolve(id); });
cc.audioEngine.setFinishCallback(id, () => { resolve(id); if (!noStop) this.resumeBgmMusic(); });
})
}
private bgmId;
playLocalBgmAudio(audioName = "bgm") {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
this.bgmId = cc.audioEngine.playMusic(audio.clip, true);
cc.audioEngine.setFinishCallback(this.bgmId, () => { resolve(this.bgmId); });
})
}
stopBgmAdudio() {
cc.audioEngine.pauseMusic();
}
resumeBgmMusic() {
cc.audioEngine.resumeMusic();
}
async showOneFirework(pos, parentNode, nodeList) {
......
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