Commit d7bbb9c5 authored by yu's avatar yu

1

parent f58e6b5c
...@@ -56,10 +56,14 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -56,10 +56,14 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
@property(cc.Node) @property(cc.Node)
goodJob: cc.Node = null; goodJob: cc.Node = null;
private audioId;
private wordAudioId;
initData() { initData() {
Game.getIns().init(this.data); Game.getIns().init(this.data);
Game.getIns().reset(); Game.getIns().reset();
this.wordItams = []; this.wordItams = [];
this.audioId = -1;
} }
initView() { initView() {
this.startGame(); this.startGame();
...@@ -73,7 +77,6 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -73,7 +77,6 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
pg.event.on("gameOver", () => { this.gameOver() }) pg.event.on("gameOver", () => { this.gameOver() })
} }
private onCat() { private onCat() {
cc.audioEngine.stopAll();
let data = Game.getIns().getCurrentPage(); let data = Game.getIns().getCurrentPage();
let audioUrl = ""; let audioUrl = "";
if (data.page % 2 == 0) { if (data.page % 2 == 0) {
...@@ -81,15 +84,23 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -81,15 +84,23 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
} else { } else {
audioUrl = Game.getIns().waitAudio; audioUrl = Game.getIns().waitAudio;
} }
if (this.audioId >= 0) cc.audioEngine.stopEffect(this.audioId);
this.setMaoAni("begin"); this.setMaoAni("begin");
pg.audio.playAudioByUrl(audioUrl).then(() => { pg.audio.playAudioByUrl(audioUrl, (id) => {
this.audioId = id;
}).then(() => {
this.setMaoAni("normal"); this.setMaoAni("normal");
}); });
} }
private onWordAudio() { private onWordAudio() {
let data = Game.getIns().getCurrentPage(); let data = Game.getIns().getCurrentPage();
cc.audioEngine.stopAll(); if (this.wordAudioId >= 0) cc.audioEngine.stopEffect(this.wordAudioId);
pg.audio.playAudioByUrl(data.wordAudio); this.setMaoAni("begin");
pg.audio.playAudioByUrl(data.wordAudio, (id) => {
this.wordAudioId = id;
}).then(() => {
this.setMaoAni("normal");
});
} }
//根据两点获取距离 //根据两点获取距离
private getDistance(p1, p2) { private getDistance(p1, p2) {
...@@ -123,6 +134,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -123,6 +134,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
pg.audio.playAudioByUrl(audioUrl).then(() => { pg.audio.playAudioByUrl(audioUrl).then(() => {
this.setMaoAni("normal"); this.setMaoAni("normal");
});; });;
this.progressBar.getComponent(cc.ProgressBar).progress = 0;
this.nextPage(); this.nextPage();
} }
nextPage() { nextPage() {
...@@ -131,7 +143,6 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -131,7 +143,6 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
//自动创建卡片 //自动创建卡片
this.createCrads(data); this.createCrads(data);
this.showTop(data); this.showTop(data);
// this.progressBar.getComponent(cc.ProgressBar).progress = 0;
} }
private showTop(data) { private showTop(data) {
let img = cc.find("tips/img", this.node); let img = cc.find("tips/img", this.node);
...@@ -303,26 +314,27 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -303,26 +314,27 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
private roundOver() { private roundOver() {
if (this.checkRoundOver()) { if (this.checkRoundOver()) {
this.word_layout.active = false; this.word_layout.active = false;
this.word_layout.removeAllChildren();
cc.tween(this.nor_label).to(0.1, { opacity: 255 }).start(); cc.tween(this.nor_label).to(0.1, { opacity: 255 }).start();
let data = Game.getIns().getCurrentPage(); let data = Game.getIns().getCurrentPage();
pg.audio.playAudioByUrl(data.wordAudio).then(async () => { pg.audio.playAudioByUrl(data.wordAudio).then(() => {
let pro = this.progressBar.getComponent(cc.ProgressBar); let pro = this.progressBar.getComponent(cc.ProgressBar);
let add = Game.getIns().addPage(); let p = Game.getIns().page / Game.getIns().getTotalPageNum();
if (add) { cc.tween(pro).to(1, { progress: p }).delay(1).call(() => {
await pg.time.delay(1); let add = Game.getIns().addPage();
this.nextPage() if (add) {
} else { this.nextPage()
if (Game.getIns().roundCount == 1) {
Game.getIns().roundCount = 2;
Game.getIns().page = 1;
cc.tween(pro).to(1, { progress: 1 }).delay(1).call(() => {
this.startGame();
}).start();
} else { } else {
this.goodJob.active = true; if (Game.getIns().roundCount == 1) {
this.gameOver(); Game.getIns().roundCount = 2;
Game.getIns().page = 1;
this.startGame();
} else {
this.goodJob.active = true;
this.gameOver();
}
} }
} }).start();
}) })
} }
} }
......
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