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