Commit 45810069 authored by Tt's avatar Tt

fix(play): 修复双模态下音频播放和鱼动画问题

parent fd3bd85f
...@@ -50,7 +50,7 @@ import { FormData, Position, PositionMap, Stage, Question } from './interfaces'; ...@@ -50,7 +50,7 @@ import { FormData, Position, PositionMap, Stage, Question } from './interfaces';
let defaultFormData: FormData = { let defaultFormData: FormData = {
"score": 0, "score": 0,
"title": "", "title": "",
"doubleModal": true, "doubleModal": false,
"questionText": "", "questionType": "read", "questionTextAudio": "", "questionText": "", "questionType": "read", "questionTextAudio": "",
"bgAudio": "", "bgAudio": "",
"questions": [ "questions": [
...@@ -972,8 +972,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -972,8 +972,14 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_lastFishTime = 0; // 重置上次生成鱼的时间,使下一帧立即生成鱼 this.m_lastFishTime = 0; // 重置上次生成鱼的时间,使下一帧立即生成鱼
// 每一个stage开始的时候播放一次正确问题的音频 // 每一个stage开始的时候播放一次正确问题的音频
if (currentQuestion.correctQuestion && currentQuestion.correctQuestion.audio && (this.g_formData.doubleModal || this.currentStageIndex !== 0)) { if (currentQuestion.correctQuestion && currentQuestion.correctQuestion.audio) {
this.g_cartoon.playAudio(currentQuestion.correctQuestion.audio); if ((this.g_formData.doubleModal || this.currentStageIndex !== 0)) {
setTimeout(() => {
this.g_cartoon.playAudio(currentQuestion.correctQuestion.audio);
}, 500);
} else {
this.g_cartoon.playAudio(currentQuestion.correctQuestion.audio);
}
} }
} }
...@@ -1570,6 +1576,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1570,6 +1576,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.cat_right = this.createCat('right'); // 创建右侧猫 this.cat_right = this.createCat('right'); // 创建右侧猫
} else { } else {
this.cat_center = this.createCat('center'); // 创建中间猫 this.cat_center = this.createCat('center'); // 创建中间猫
this.currentPlayer = 'center';
} }
} }
...@@ -1586,7 +1593,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1586,7 +1593,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.cat_left["child_mao_hui_zuo"].ref.visible = false; this.cat_left["child_mao_hui_zuo"].ref.visible = false;
this.cat_left["child_mao_hui_pa"].ref.visible = false; this.cat_left["child_mao_hui_pa"].ref.visible = false;
this.cat_left["child_gan"].ref.visible = true; this.cat_left["child_gan"].ref.visible = true;
} else { } else if (this.currentPlayer == 'right') {
this.cat_right["child_mao_ju_zuo"].ref.visible = false; this.cat_right["child_mao_ju_zuo"].ref.visible = false;
this.cat_right["child_mao_ju_pa"].ref.visible = false; this.cat_right["child_mao_ju_pa"].ref.visible = false;
this.cat_right["child_mao_hui_zuo"].ref.visible = true; this.cat_right["child_mao_hui_zuo"].ref.visible = true;
...@@ -1628,7 +1635,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1628,7 +1635,7 @@ export class PlayComponent implements OnInit, OnDestroy {
tempFish.ref.y = fishGlobalY; tempFish.ref.y = fishGlobalY;
// 3. 获取水桶的全局位置 // 3. 获取水桶的全局位置
const tong = this.getCurrentCat()[this.currentPlayer == 'left' ? 'child_tong_left' : 'child_tong_right']; const tong = this.getCurrentCat()[this.currentPlayer == 'right' ? 'child_tong_right' : 'child_tong_left'];
const tongGlobalX = this.getCurrentCat().ref.x + tong.ref.x; const tongGlobalX = this.getCurrentCat().ref.x + tong.ref.x;
const tongGlobalY = this.getCurrentCat().ref.y + tong.ref.y; const tongGlobalY = this.getCurrentCat().ref.y + tong.ref.y;
...@@ -1649,7 +1656,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1649,7 +1656,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// 动画完成后移除临时小鱼 // 动画完成后移除临时小鱼
this.m_renderArr = this.m_renderArr.filter(item => item !== tempFish.ref); this.m_renderArr = this.m_renderArr.filter(item => item !== tempFish.ref);
tempFish.ref.visible = false; tempFish.ref.visible = false;
this.playShuiHuaAnimation(this.getCurrentCat()[this.currentPlayer == 'left' ? 'child_tong_left_shui_hua' : 'child_tong_right_shui_hua']); this.playShuiHuaAnimation(this.getCurrentCat()[this.currentPlayer == 'right' ? 'child_tong_right_shui_hua' : 'child_tong_left_shui_hua']);
this.saveFishSuccess(fish); this.saveFishSuccess(fish);
}, },
TWEEN.Easing.Quadratic.Out // 使用缓动函数使动画更平滑 TWEEN.Easing.Quadratic.Out // 使用缓动函数使动画更平滑
......
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