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

fix:bugs

parent 82ad6a40
......@@ -195,6 +195,10 @@ cc.Class({
starLayout.zIndex = 2;
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++) {
const starBase = cc.instantiate(cc.find('StarBase'));
starBase.name = `starBase_${i}`;
......@@ -243,6 +247,7 @@ cc.Class({
await asyncDelay(0.6);
await asyncTweenTo(starBig, 0.8, { scale: 0 }, { easing: 'quadOut' });
await this.playAudioSync('question');
},
isEndGame() {
......@@ -267,7 +272,6 @@ cc.Class({
this.createStars();
await this.showGuns();
await this.playAudioSync('question');
await this.playQuestionAudio();
this.startShowBalls();
},
......@@ -363,30 +367,32 @@ cc.Class({
if (ball.canNotTouch) {
return;
}
ball.canNotTouch = true;
if (answer.rightAnswer) {
ball.canNotTouch = true;
}
const location = event.getLocation();
await this.shootTarget(ball, location, true);
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 {
if (!answer.rightAnswer) {
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({
return ball;
},
onBallClicked(answer) {
},
createImgBall(answer) {
const ball = cc.instantiate(cc.find('BallImg'));
const img = cc.find('Mask/AnsterImg', ball);
const mask = cc.find('Mask', ball);
getSpriteFrimeByUrl(answer.answerImg, (spriteFrame) => {
img.getComponent(cc.Sprite).spriteFrame = spriteFrame;
img.scale = Math.min(1, mask.width / img.width, mask.height / img.height);
});
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