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

feat: 解决重叠问题;选项正确后读音

parent 18850446
...@@ -324,6 +324,7 @@ cc.Class({ ...@@ -324,6 +324,7 @@ cc.Class({
} }
}, },
createBall(answer) { createBall(answer) {
let ball = null; let ball = null;
if (answer.answerType == 'img') { if (answer.answerType == 'img') {
...@@ -331,11 +332,24 @@ cc.Class({ ...@@ -331,11 +332,24 @@ cc.Class({
} else { } else {
ball = this.createTextBall(answer); ball = this.createTextBall(answer);
} }
const bg = cc.find('Canvas/bg'); const bg = cc.find('Canvas/bg');
ball.x = bg.width / 4 * (RandomInt(0, 3) - 1) + RandomInt(-50, 50); let ballPosXBaseList = [-bg.width / 4, 0, bg.width / 4];
if (this.lastBallPosXBase !== undefined) {
ballPosXBaseList = ballPosXBaseList.filter(posX => posX != this.lastBallPosXBase);
}
const ballPosXBase = ballPosXBaseList[RandomInt(ballPosXBaseList.length)];
ball.x = ballPosXBase + RandomInt(-50, 50);
ball.y = -bg.height; ball.y = -bg.height;
ball.parent = bg; ball.parent = bg;
this.lastBallPosXBase = ballPosXBase;
if (answer.rightAnswer) {
ball.audio = answer.answerAudio;
}
cc.tween(ball.getChildByName('bg')) cc.tween(ball.getChildByName('bg'))
.to(0.2, { scaleX: 0.98, scaleY: 1.05 }) .to(0.2, { scaleX: 0.98, scaleY: 1.05 })
.to(0.2, { scaleX: 1.02, scaleY: 0.94 }) .to(0.2, { scaleX: 1.02, scaleY: 0.94 })
...@@ -383,7 +397,7 @@ cc.Class({ ...@@ -383,7 +397,7 @@ cc.Class({
const time2 = time - time1; const time2 = time - time1;
cc.tween(ball) cc.tween(ball)
.to(time1, { y: bg.height / 2 - ball.height / 2 - 50 }, { easing: 'quadOut' }) .to(time1, { y: bg.height / 2 - ball.height / 2 - 50 }, { easing: 'quadOut' })
.delay(0.75) .delay(0.5)
.to(time2, { y: bg.height }, { easing: 'quadIn' }) .to(time2, { y: bg.height }, { easing: 'quadIn' })
.removeSelf() .removeSelf()
.start(); .start();
...@@ -505,7 +519,7 @@ cc.Class({ ...@@ -505,7 +519,7 @@ cc.Class({
}, },
async targetDistroy(node) { async targetDistroy(node) {
this.playAudio('right'); node.stopAllActions();
const bg = node.getChildByName('bg'); const bg = node.getChildByName('bg');
bg.active = false; bg.active = false;
const DistroyAnime = node.getChildByName('DistroyAnime'); const DistroyAnime = node.getChildByName('DistroyAnime');
...@@ -514,6 +528,10 @@ cc.Class({ ...@@ -514,6 +528,10 @@ cc.Class({
cc.tween(Mask) cc.tween(Mask)
.to(0.5, { opacity: 0 }) .to(0.5, { opacity: 0 })
.start(); .start();
await this.playAudioSync('right');
await playAudioByUrlSync(node.audio);
node.removeFromParent();
}, },
async targetLaugh(node) { async targetLaugh(node) {
......
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