Commit d7bbb9c5 authored by yu's avatar yu

1

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