Commit 85ea6811 authored by yu's avatar yu

题目随机

parent d7bbb9c5
...@@ -88,13 +88,21 @@ export default class Game { ...@@ -88,13 +88,21 @@ export default class Game {
this.page = 1; this.page = 1;
this.start = true; this.start = true;
this.lists = []; this.lists = [];
let arr = [];
for (let i = 0; i < this.data.length; i++) { for (let i = 0; i < this.data.length; i++) {
let data = this.data[i]; let data = this.data[i];
this.lists.push(new Item(data, i)); arr.push(new Item(data, i));
} }
this.lists.sort(function () {
return (0.5 - Math.random()); let page = arr[0].page;
}); do {
arr.sort(() => Math.random() - 0.5);
} while (arr[0].page == page);
arr.forEach((item, idx) => {
item.page = idx + 1;
this.lists.push(item);
})
} }
checkSuccess(arr: Option[]) { checkSuccess(arr: Option[]) {
let data = this.getCurrentPage(); let data = this.getCurrentPage();
......
This diff is collapsed.
...@@ -259,9 +259,8 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -259,9 +259,8 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
itemBg.errorCount++; itemBg.errorCount++;
if (itemBg.errorCount >= 3) { if (itemBg.errorCount >= 3) {
this.errorThere(target, itemBg); this.errorThere(target, itemBg);
this.playLocalAudio("right").then(() => { this.playLocalAudio("right");
this.roundOver(); this.roundOver();
});
} else { } else {
this.playLocalAudio("error"); this.playLocalAudio("error");
this.moveError(target, data); this.moveError(target, data);
...@@ -277,9 +276,8 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -277,9 +276,8 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
let line = cc.find("line", item); let line = cc.find("line", item);
word.active = true; word.active = true;
line.active = false; line.active = false;
this.playLocalAudio("right").then(() => { this.playLocalAudio("right");
this.roundOver(); this.roundOver();
});
} }
private moveError(target, data) { private moveError(target, data) {
this.op_layout.children.forEach((item) => { this.op_layout.children.forEach((item) => {
...@@ -313,9 +311,12 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -313,9 +311,12 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
} }
private roundOver() { private roundOver() {
if (this.checkRoundOver()) { if (this.checkRoundOver()) {
cc.tween(this.nor_label)
.delay(0.5).call(() => {
this.word_layout.active = false; this.word_layout.active = false;
this.word_layout.removeAllChildren(); this.word_layout.removeAllChildren();
cc.tween(this.nor_label).to(0.1, { opacity: 255 }).start(); })
.to(0.1, { opacity: 255 }).delay(0.5).call(() => {
let data = Game.getIns().getCurrentPage(); let data = Game.getIns().getCurrentPage();
pg.audio.playAudioByUrl(data.wordAudio).then(() => { pg.audio.playAudioByUrl(data.wordAudio).then(() => {
let pro = this.progressBar.getComponent(cc.ProgressBar); let pro = this.progressBar.getComponent(cc.ProgressBar);
...@@ -336,6 +337,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent { ...@@ -336,6 +337,7 @@ export default class PuzzleJigsaw extends MyCocosSceneComponent {
} }
}).start(); }).start();
}) })
}).start();
} }
} }
private checkRoundOver() { private checkRoundOver() {
......
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