Commit 18850446 authored by 范雪寒's avatar 范雪寒

feat: 调整出现速度

parent b2b6dce7
......@@ -23,7 +23,7 @@ cc.Class({
},
ctor() {
this.createSpeed = [1250, 1000, 1000, 800, 800, 640, 640, 512, 512];
this.createSpeed = [750, 1500, 1000, 800, 800, 640, 640, 512, 512];
this.moveSpeed = [5, 5, 4, 4, 3.2, 3.2, 2.56, 2.56, 2.048, 2.048];
},
......@@ -265,16 +265,26 @@ cc.Class({
currentRightNumber: 0
};
this.createStars();
this.showGuns();
await this.showGuns();
await this.playAudioSync('question');
await this.playQuestionAudio();
this.startShowBalls();
},
showGuns() {
const bg = cc.find('Canvas/bg');
const gunBase = cc.find('Canvas/bg/GunBase');
this.playAudio('move');
asyncTweenTo(gunBase, 0.5, { y: -bg.height / 2 });
return new Promise((resolve, reject) => {
try {
const bg = cc.find('Canvas/bg');
const gunBase = cc.find('Canvas/bg/GunBase');
asyncTweenTo(gunBase, 0.5, { y: -bg.height / 2 });
this.playAudio('move', () => {
resolve();
});
} catch (e) {
reject();
}
});
},
hideGuns() {
......@@ -322,7 +332,7 @@ cc.Class({
ball = this.createTextBall(answer);
}
const bg = cc.find('Canvas/bg');
ball.x = bg.width / 2 * (RandomInt(0, 2) - 0.5) + RandomInt(-50, 50);
ball.x = bg.width / 4 * (RandomInt(0, 3) - 1) + RandomInt(-50, 50);
ball.y = -bg.height;
ball.parent = bg;
......@@ -333,7 +343,7 @@ cc.Class({
.repeatForever()
.start();
this.playAudio('appare', null, 0.4);
this.playAudio('appare', null, 0.1);
ball.on('touchstart', async (event) => {
if (ball.canNotTouch) {
......@@ -367,8 +377,14 @@ cc.Class({
const currentQuestion = this.data.questionList[this._status.currentQuestionIdx];
const time = this.moveSpeed[currentQuestion.speedLevel];
const targetY1 = bg.height / 2 - ball.height / 2 - 50;
const targetY2 = bg.height;
const time1 = time * (ball.y - targetY1) / (ball.y - targetY2);
const time2 = time - time1;
cc.tween(ball)
.to(time, { y: bg.height })
.to(time1, { y: bg.height / 2 - ball.height / 2 - 50 }, { easing: 'quadOut' })
.delay(0.75)
.to(time2, { y: bg.height }, { easing: 'quadIn' })
.removeSelf()
.start();
......@@ -394,7 +410,6 @@ cc.Class({
cc.tween(text)
.delay(0)
.call(() => {
console.log('text = ' + answer.answerTxt + ', text.width = ' + text.width);
text.scale = Math.min(mask.width / text.width, 1);
})
.start();
......@@ -422,11 +437,9 @@ cc.Class({
if (!currentQuestion) {
return;
}
this.playAudio('question', async () => {
this.speakerBlink();
await playAudioByUrlSync(currentQuestion.questionAudio);
this.speakerStopBlink();
});
this.speakerBlink();
await playAudioByUrlSync(currentQuestion.questionAudio);
this.speakerStopBlink();
},
speakerList: null,
......@@ -524,5 +537,16 @@ cc.Class({
cb();
}
});
},
async playAudioSync(audioName, value) {
return new Promise((resolve, reject) => {
try {
this.playAudio(audioName, () => {
resolve();
}, value);
} catch (e) {
reject();
}
});
}
});
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