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

feat: 调整出现速度

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