Commit 15469c46 authored by 范雪寒's avatar 范雪寒

fix:bugs

parent 82ad6a40
...@@ -195,6 +195,10 @@ cc.Class({ ...@@ -195,6 +195,10 @@ cc.Class({
starLayout.zIndex = 2; starLayout.zIndex = 2;
const paddingY = starLayout.getComponent(cc.Layout).spacingY; const paddingY = starLayout.getComponent(cc.Layout).spacingY;
if (this.data.questionList.length == 1) {
starLayout.active = false;
}
for (let i = 0; i < this.data.questionList.length; i++) { for (let i = 0; i < this.data.questionList.length; i++) {
const starBase = cc.instantiate(cc.find('StarBase')); const starBase = cc.instantiate(cc.find('StarBase'));
starBase.name = `starBase_${i}`; starBase.name = `starBase_${i}`;
...@@ -243,6 +247,7 @@ cc.Class({ ...@@ -243,6 +247,7 @@ cc.Class({
await asyncDelay(0.6); await asyncDelay(0.6);
await asyncTweenTo(starBig, 0.8, { scale: 0 }, { easing: 'quadOut' }); await asyncTweenTo(starBig, 0.8, { scale: 0 }, { easing: 'quadOut' });
await this.playAudioSync('question');
}, },
isEndGame() { isEndGame() {
...@@ -267,7 +272,6 @@ cc.Class({ ...@@ -267,7 +272,6 @@ cc.Class({
this.createStars(); this.createStars();
await this.showGuns(); await this.showGuns();
await this.playAudioSync('question');
await this.playQuestionAudio(); await this.playQuestionAudio();
this.startShowBalls(); this.startShowBalls();
}, },
...@@ -363,30 +367,32 @@ cc.Class({ ...@@ -363,30 +367,32 @@ cc.Class({
if (ball.canNotTouch) { if (ball.canNotTouch) {
return; return;
} }
ball.canNotTouch = true; if (answer.rightAnswer) {
ball.canNotTouch = true;
}
const location = event.getLocation(); const location = event.getLocation();
await this.shootTarget(ball, location, true); await this.shootTarget(ball, location, true);
if (answer.rightAnswer) { if (!answer.rightAnswer) {
this.targetDistroy(ball);
this._status.currentRightNumber++;
const currentQuestion = this.data.questionList[this._status.currentQuestionIdx];
this.updateRightNumber();
if (this._status.currentRightNumber >= currentQuestion.rigthNumber) {
this.stopShowBalls();
await asyncDelay(0.5);
await this.showStar();
this._status.currentRightNumber = 0;
this._status.currentQuestionIdx++;
if (this.isEndGame()) {
this.onGameEnd();
} else {
await asyncDelay(1.5);
await this.playQuestionAudio();
this.startShowBalls();
}
}
} else {
this.targetLaugh(ball); this.targetLaugh(ball);
return;
}
this.targetDistroy(ball);
this._status.currentRightNumber++;
const currentQuestion = this.data.questionList[this._status.currentQuestionIdx];
this.updateRightNumber();
if (this._status.currentRightNumber >= currentQuestion.rigthNumber) {
this.stopShowBalls();
await asyncDelay(0.5);
await this.showStar();
this._status.currentRightNumber = 0;
this._status.currentQuestionIdx++;
if (this.isEndGame()) {
this.onGameEnd();
} else {
await asyncDelay(1.5);
await this.playQuestionAudio();
this.startShowBalls();
}
} }
}); });
...@@ -407,11 +413,17 @@ cc.Class({ ...@@ -407,11 +413,17 @@ cc.Class({
return ball; return ball;
}, },
onBallClicked(answer) {
},
createImgBall(answer) { createImgBall(answer) {
const ball = cc.instantiate(cc.find('BallImg')); const ball = cc.instantiate(cc.find('BallImg'));
const img = cc.find('Mask/AnsterImg', ball); const img = cc.find('Mask/AnsterImg', ball);
const mask = cc.find('Mask', ball);
getSpriteFrimeByUrl(answer.answerImg, (spriteFrame) => { getSpriteFrimeByUrl(answer.answerImg, (spriteFrame) => {
img.getComponent(cc.Sprite).spriteFrame = spriteFrame; img.getComponent(cc.Sprite).spriteFrame = spriteFrame;
img.scale = Math.min(1, mask.width / img.width, mask.height / img.height);
}); });
return ball; return ball;
}, },
......
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