Commit b1b59800 authored by liujiangnan's avatar liujiangnan

fix: 断线恢复问题

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