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