Commit b1b59800 authored by liujiangnan's avatar liujiangnan

fix: 断线恢复问题

parent 9669e4ad
......@@ -224,13 +224,13 @@ cc.Class({
}],
quesion: {
selected: false,
},
currentShowOptionIdx: null,
currentShowQuestion: false
}
}
}
},
clickedBtn: false,
initListener() {
this.initNetworkListener();
......@@ -240,12 +240,14 @@ cc.Class({
if (!this.teachFlag) {
return;
}
if (this._status.currentShowOptionIdx !== null) {
if(this.clickedBtn){
return;
}
if (this._status.currentShowQuestion !== false) {
if(this.gameEnd){
return;
}
this.clickedBtn = true;
this._status.options[idx].selected = true;
this.sendServerEvent('clickOption', { data: { idx: idx }, status: this._status });
});
});
......@@ -255,13 +257,15 @@ cc.Class({
if (!this.teachFlag) {
return;
}
if (this._status.currentShowOptionIdx !== null) {
if(this.clickedBtn){
return;
}
if (this._status.currentShowQuestion !== false) {
if(this.gameEnd){
return;
}
this.sendServerEvent('clickQuestion', null);
this.clickedBtn = true;
this._status.quesion.selected = true;
this.sendServerEvent('clickQuestion', { data: null, status: this._status });
});
},
......@@ -297,20 +301,16 @@ cc.Class({
}
window.courseware.onEvent('clickOption', async (data, next) => {
await this.showOption(data.data.idx);
next();
});
window.courseware.onEvent('clickQuestion', async (data, next) => {
await this.showQuestion();
next();
});
window.courseware.onEvent('hideOption', async (data, next) => {
await this.hideOption();
this.updateStatus(data.status);
this.clickedBtn = false;
next();
});
window.courseware.onEvent('hideQuestion', async (data, next) => {
window.courseware.onEvent('clickQuestion', async (data, next) => {
await this.showQuestion();
await this.hideQuestion();
this.updateStatus(data.status);
this.clickedBtn = false;
next();
});
},
......@@ -375,9 +375,6 @@ cc.Class({
starOff.opacity = 255;
}
}
this._status.currentShowOptionIdx = null;
this._status.currentShowQuestion = false;
},
initOptions() {
......@@ -445,6 +442,7 @@ cc.Class({
});
},
currentShowOptionIdx: null,
async showOption(idx) {
console.log("idx:", idx);
const optionNode = cc.find(`Canvas/bg/book/option/option_${idx}`);
......@@ -454,7 +452,7 @@ cc.Class({
return;
}
this._status.currentShowOptionIdx = idx;
this.currentShowOptionIdx = idx;
const maskBase = cc.find('Canvas/bg/maskBase');
const oldPosition = optionNode.getPosition();
......@@ -478,7 +476,6 @@ cc.Class({
asyncTweenTo(imageStarOn, 0.2, { opacity: 255 }),
asyncTweenTo(imageStarOff, 0.2, { opacity: 0 })
]);
this._status.options[idx].selected = true;
this.playAudioByNodeName('right');
const image = optionNode.getChildByName('image');
......@@ -492,15 +489,10 @@ cc.Class({
await asyncTweenTo(label, 0.15, { scale: 1.1 }, { easing: 'sineIn' });
await asyncTweenTo(label, 0.1, { scale: 1 }, { easing: 'sineOut' });
await asyncDelay(2);
if (this.teachFlag) {
// 以老师的同步消息为准
this.sendServerEvent('hideOption', { data: { idx: idx }, status: this._status });
}
},
async hideOption() {
const idx = this._status.currentShowOptionIdx;
const idx = this.currentShowOptionIdx;
if (idx === null) {
return;
}
......@@ -527,7 +519,6 @@ cc.Class({
},
async showQuestion() {
this._status.currentShowQuestion = true;
const questionNode = cc.find('Canvas/bg/book/question/questionNode');
if (!questionNode) {
return;
......@@ -560,17 +551,11 @@ cc.Class({
asyncTweenTo(starOff, 0.2, { opacity: 0 })
]);
this._status.quesion.selected = true;
for (const label of this.questionLabelList) {
await asyncTweenTo(label, 0.2, { scale: 1.3 }, { easing: 'sineInOut' });
await asyncTweenTo(label, 0.2, { scale: 1.0 }, { easing: 'sineInOut' });
}
await asyncDelay(2);
if (this.teachFlag) {
// 以老师的同步消息为准
this.sendServerEvent('hideQuestion', { data: null, status: this._status });
}
},
async hideQuestion() {
......
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