Commit 72501a45 authored by 范雪寒's avatar 范雪寒

Merge branch 'master' of http://vcs.ireadabc.com/template/AK09

parents 1de17db6 b1b59800
...@@ -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);
await this.hideOption();
this.updateStatus(data.status);
this.clickedBtn = false;
next(); next();
}); });
window.courseware.onEvent('clickQuestion', async (data, next) => { window.courseware.onEvent('clickQuestion', async (data, next) => {
await this.showQuestion(); await this.showQuestion();
next(); await this.hideQuestion();
});
window.courseware.onEvent('hideOption', (data, next) => {
this.hideOption();
this.updateStatus(data.status);
next();
});
window.courseware.onEvent('hideQuestion', (data, next) => {
this.hideQuestion();
this.updateStatus(data.status); this.updateStatus(data.status);
this.clickedBtn = false;
next(); next();
}); });
}, },
...@@ -332,6 +332,8 @@ cc.Class({ ...@@ -332,6 +332,8 @@ cc.Class({
tipNode.active = this.teachFlag; tipNode.active = this.teachFlag;
}, },
gameEnd: false,
isShowTemplateEndAnima: false,
updateStatus(status) { updateStatus(status) {
this._status = status; this._status = status;
this._status.options.forEach((optionData, idx) => { this._status.options.forEach((optionData, idx) => {
...@@ -350,9 +352,11 @@ cc.Class({ ...@@ -350,9 +352,11 @@ cc.Class({
} }
}); });
const allOptionSelected = this._status.options.every(optionData => optionData.selected); const allOptionSelected = this._status.options.every(optionData => optionData.selected);
if (this._status.quesion.selected && allOptionSelected) { this.gameEnd = this._status.quesion.selected && allOptionSelected;
if (this.gameEnd && !this.isShowTemplateEndAnima) {
this.isShowTemplateEndAnima = true;
cc.tween({}).delay(2).call(() => { cc.tween({}).delay(2).call(() => {
this.showTemplateEndAnima(); this.showTemplateEndAnima();
}).start(); }).start();
...@@ -438,20 +442,17 @@ cc.Class({ ...@@ -438,20 +442,17 @@ 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}`);
if (!optionNode) { if (!optionNode) {
console.log("!optionNode:"); console.log("!optionNode:");
return; return;
} }
this._status.currentShowOptionIdx = idx; this.currentShowOptionIdx = idx;
const mask = cc.find('Canvas/bg/maskBase/mask');
cc.tween(mask).to(0.5, { opacity: 255 }).start();
const maskBase = cc.find('Canvas/bg/maskBase'); const maskBase = cc.find('Canvas/bg/maskBase');
const oldPosition = optionNode.getPosition(); const oldPosition = optionNode.getPosition();
...@@ -461,13 +462,20 @@ cc.Class({ ...@@ -461,13 +462,20 @@ cc.Class({
optionNode.parent = maskBase; optionNode.parent = maskBase;
optionNode.setPosition(newPos); optionNode.setPosition(newPos);
optionNode.oldPosition = cc.v2(oldPosition.x, oldPosition.y); optionNode.oldPosition = cc.v2(oldPosition.x, oldPosition.y);
await asyncTweenTo(optionNode, 0.6, { x: 0, y: 0, scale: 1.7 }, { easing: 'sineInOut' });
const mask = cc.find('Canvas/bg/maskBase/mask');
await Promise.all([
asyncTweenTo(mask, 0.5, { opacity: 255 }),
asyncTweenTo(optionNode, 0.6, { x: 0, y: 0, scale: 1.7 }, { easing: 'sineInOut' })
]);
const imageStarOn = optionNode.getChildByName('ImageStarOn'); const imageStarOn = optionNode.getChildByName('ImageStarOn');
const imageStarOff = optionNode.getChildByName('ImageStarOff'); const imageStarOff = optionNode.getChildByName('ImageStarOff');
asyncTweenTo(imageStarOn, 0.2, { opacity: 255 });
asyncTweenTo(imageStarOff, 0.2, { opacity: 0 }); await Promise.all([
this._status.options[idx].selected = true; asyncTweenTo(imageStarOn, 0.2, { opacity: 255 }),
asyncTweenTo(imageStarOff, 0.2, { opacity: 0 })
]);
this.playAudioByNodeName('right'); this.playAudioByNodeName('right');
const image = optionNode.getChildByName('image'); const image = optionNode.getChildByName('image');
...@@ -481,56 +489,43 @@ cc.Class({ ...@@ -481,56 +489,43 @@ 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);
this.sendServerEvent('hideOption', { data: { idx: idx }, status: this._status });
}, },
hideOption() { async hideOption() {
const idx = this._status.currentShowOptionIdx; const idx = this.currentShowOptionIdx;
if (idx === null) { if (idx === null) {
console.log('idx = ' + idx);
return; return;
} }
const mask = cc.find('Canvas/bg/maskBase/mask');
cc.tween(mask).to(0.5, { opacity: 0 }).start();
const optionNode = cc.find(`Canvas/bg/maskBase/option_${idx}`); const optionNode = cc.find(`Canvas/bg/maskBase/option_${idx}`);
if (!optionNode) { if (!optionNode) {
console.log('optionNode is null'); console.log('optionNode is null');
return; return;
} }
const optionBase = cc.find(`Canvas/bg/book/option`); const optionBase = cc.find(`Canvas/bg/book/option`);
const maskBase = cc.find('Canvas/bg/maskBase'); const maskBase = cc.find('Canvas/bg/maskBase');
const movePos = maskBase.convertToNodeSpaceAR( const movePos = maskBase.convertToNodeSpaceAR(
optionBase.convertToWorldSpaceAR(optionNode.oldPosition) optionBase.convertToWorldSpaceAR(optionNode.oldPosition)
); );
if (!optionNode.hideAction) { const mask = cc.find('Canvas/bg/maskBase/mask');
optionNode.hideAction = cc.tween(optionNode) await Promise.all([
.to(0.6, { x: movePos.x, y: movePos.y, scale: 1 }, { easing: 'sineInOut' }) asyncTweenTo(mask, 0.5, { opacity: 0 }),
.call(() => { asyncTweenTo(optionNode, 0.6, { x: movePos.x, y: movePos.y, scale: 1 }, { easing: 'sineInOut' })
optionNode.parent = optionBase; ]);
optionNode.setPosition(optionNode.oldPosition);
optionNode.hideAction = null; optionNode.parent = optionBase;
this._status.currentShowOptionIdx = null; optionNode.setPosition(optionNode.oldPosition);
})
.start();
}
}, },
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;
} }
const mask = cc.find('Canvas/bg/maskBase/mask'); const mask = cc.find('Canvas/bg/maskBase/mask');
cc.tween(mask).to(0.5, { opacity: 255 }).start();
const questionBg = questionNode.getChildByName('bg'); const questionBg = questionNode.getChildByName('bg');
cc.tween(questionBg).to(0.5, { opacity: 255 }).start();
const oldPosition = questionNode.getPosition(); const oldPosition = questionNode.getPosition();
questionNode.oldPosition = oldPosition; questionNode.oldPosition = oldPosition;
...@@ -541,22 +536,26 @@ cc.Class({ ...@@ -541,22 +536,26 @@ cc.Class({
); );
questionNode.parent = maskBase; questionNode.parent = maskBase;
questionNode.setPosition(newPos); questionNode.setPosition(newPos);
await asyncTweenTo(questionNode, 0.6, { x: 0, y: 0, scale: 1.4 }, { easing: 'sineInOut' }); await Promise.all([
asyncTweenTo(mask, 0.5, { opacity: 255 }),
asyncTweenTo(questionBg, 0.5, { opacity: 255 }),
asyncTweenTo(questionNode, 0.6, { x: 0, y: 0, scale: 1.4 }, { easing: 'sineInOut' })
]);
this.playAudioByNodeName('right'); this.playAudioByNodeName('right');
const starOn = cc.find('questionLayout/starNode/ImageStarOn', questionNode); const starOn = cc.find('questionLayout/starNode/ImageStarOn', questionNode);
const starOff = cc.find('questionLayout/starNode/ImageStarOff', questionNode); const starOff = cc.find('questionLayout/starNode/ImageStarOff', questionNode);
asyncTweenTo(starOn, 0.2, { opacity: 255 });
await asyncTweenTo(starOff, 0.2, { opacity: 0 });
this._status.quesion.selected = true; await Promise.all([
asyncTweenTo(starOn, 0.2, { opacity: 255 }),
asyncTweenTo(starOff, 0.2, { opacity: 0 })
]);
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);
this.sendServerEvent('hideQuestion', { data: null, status: this._status });
}, },
async hideQuestion() { async hideQuestion() {
...@@ -566,29 +565,21 @@ cc.Class({ ...@@ -566,29 +565,21 @@ cc.Class({
} }
const mask = cc.find('Canvas/bg/maskBase/mask'); const mask = cc.find('Canvas/bg/maskBase/mask');
cc.tween(mask).to(0.5, { opacity: 0 }).start();
const questionBg = questionNode.getChildByName('bg'); const questionBg = questionNode.getChildByName('bg');
cc.tween(questionBg).to(0.5, { opacity: 0 }).start();
const questionBase = cc.find('Canvas/bg/book/question'); const questionBase = cc.find('Canvas/bg/book/question');
const newPos = questionNode.parent.convertToNodeSpaceAR( const newPos = questionNode.parent.convertToNodeSpaceAR(
questionBase.convertToWorldSpaceAR(questionNode.oldPosition) questionBase.convertToWorldSpaceAR(questionNode.oldPosition)
); );
if (!questionNode.hideAction) { await Promise.all([
questionNode.hideAction = cc.tween(questionNode) asyncTweenTo(mask, 0.5, { opacity: 0 }),
.to(0.6, { x: newPos.x, y: newPos.y, scale: 1 }, { easing: 'sineInOut' }) asyncTweenTo(questionBg, 0.5, { opacity: 0 }),
.call(() => { asyncTweenTo(questionNode, 0.6, { x: newPos.x, y: newPos.y, scale: 1 }, { easing: 'sineInOut' })
questionNode.parent = questionBase; ]);
questionNode.x = questionNode.oldPosition.x; questionNode.parent = questionBase;
questionNode.y = questionNode.oldPosition.y; questionNode.x = questionNode.oldPosition.x;
this._status.currentShowQuestion = false; questionNode.y = questionNode.oldPosition.y;
questionNode.hideAction = null;
})
.start();
}
}, },
playAudioByNodeName(name) { playAudioByNodeName(name) {
......
...@@ -8,11 +8,11 @@ node build_check.js ...@@ -8,11 +8,11 @@ node build_check.js
set +e set +e
# cd ../form cd ../form
# npm install npm install
# npm run publish npm run publish
cd ../publish cd ../publish
......
{"ios":{"sceneName":"AK09","version":"45db2"},"android":{"sceneName":"AK09","version":"45db2"}} {"ios":{"sceneName":"AK09","version":""},"android":{"sceneName":"AK09","version":""}}
\ No newline at end of file
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