Commit f1d32675 authored by Tt's avatar Tt

游戏提交

parent d24cfced
......@@ -130,7 +130,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
startQuestion() {
// 游戏所需的初始化数据
this.currentId = 0
this.time = this.data.options.length * 3
this.time = this.data.options.length * 4
this.currentTime = this.time * 1000;
this.lengthProgress = 0
this.right = 0
......@@ -151,6 +151,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.state = State.Recording;
this.updateTitleOptions();
}
gameOver() {
this.state = State.Over;
}
private startCountDown: boolean;
update(dt) {
if (this.startCountDown) {
......@@ -186,6 +189,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
break;
case State.RecordShow:
this.state = State.Recording;
this.hideAnswer();
this.currentId++;
if (!this.getCurrentOptions()) {
this.gameOver();
return;
}
this.updateTitleOptions()
break;
}
......@@ -194,6 +203,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
getCurrentOptions() {
return this.data.options[this.currentId];
}
hideAnswer() {
let topQuestion = pg.view.find(this, 'layer_game/topQuestion');
let row = pg.view.find(this, 'layer_game/row');
let right = pg.view.find(row, 'right');
let mistake = pg.view.find(row, 'mistake');
let answer = pg.view.find(topQuestion, 'answer');
right.active = false
mistake.active = false
answer.active = false
}
//题目
updateTitleOptions() {
let topQuestion = pg.view.find(this, 'layer_game/topQuestion');
......@@ -302,8 +321,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
//错误
row.children[1].active = true
}
//添加动画
this.addAnimation(row, topQuestion)
}
//回答正确后回调
rightQuestions(row) {
......@@ -333,19 +350,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
row.children[0].active = true
}
addAnimation(row, topQuestion) {
if (this.currentId < (this.time / 5) - 1) {
//初始化
setTimeout(() => {
row.children[0].active = false
row.children[1].active = false
topQuestion.children[2].active = false
this.currentId++
}, 700);
} else {
console.log('回答完毕')
}
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
......
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