Commit 40327941 authored by Tt's avatar Tt

小鱼错误已完成

parent 8799433b
...@@ -24,7 +24,8 @@ import { ...@@ -24,7 +24,8 @@ import {
showItem, showItem,
ShapeRectNew, ShapeRectNew,
scaleItem, scaleItem,
showBlingBling showBlingBling,
alphaItem
} from "./Unit"; } from "./Unit";
import { localImages, localAudios, localImagesSize } from "./resources"; import { localImages, localAudios, localImagesSize } from "./resources";
...@@ -1067,6 +1068,24 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1067,6 +1068,24 @@ export class PlayComponent implements OnInit, OnDestroy {
* @param fish 被点击的鱼对象 * @param fish 被点击的鱼对象
*/ */
brokePaopao(fish) { brokePaopao(fish) {
// 获取当前游戏阶段
const currentStage = this.gameStages[this.currentStageIndex];
// 检查是否点击了正确的鱼
const isCorrect = fish.questionData &&
fish.questionData.audio === currentStage.correctQuestion.audio &&
fish.questionData.image === currentStage.correctQuestion.image;
console.log('Clicked fish data:', fish.questionData);
console.log('Is correct:', isCorrect);
// 保存鱼的原始速度,用于后续恢复
const originalSpeed = fish.speed || 0.3;
// 点击后立即停止鱼的运动
fish.speed = 0;
if (isCorrect) {
// 正确小鱼的处理逻辑
// 隐藏泡泡背景、小鱼和图片 // 隐藏泡泡背景、小鱼和图片
fish['child_paopao_bg'].ref.visible = false; fish['child_paopao_bg'].ref.visible = false;
fish['child_xiao_yu'].ref.visible = false; fish['child_xiao_yu'].ref.visible = false;
...@@ -1076,19 +1095,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1076,19 +1095,10 @@ export class PlayComponent implements OnInit, OnDestroy {
// 创建飞向水桶的小鱼动画 // 创建飞向水桶的小鱼动画
this.createFlyingFish(fish); this.createFlyingFish(fish);
// 获取当前游戏阶段
const currentStage = this.gameStages[this.currentStageIndex];
// 存储用户点击的鱼的数据 // 存储用户点击的鱼的数据
if (fish.questionData) { if (fish.questionData) {
this.clickedFishData.push(fish.questionData); this.clickedFishData.push(fish.questionData);
// 检查是否点击了正确的鱼
const isCorrect = fish.questionData.audio === currentStage.correctQuestion.audio &&
fish.questionData.image === currentStage.correctQuestion.image;
console.log('Clicked fish data:', fish.questionData);
console.log('Is correct:', isCorrect);
console.log('Clicked fish count:', this.clickedFishData.length); console.log('Clicked fish count:', this.clickedFishData.length);
// 计算正确点击的次数 // 计算正确点击的次数
...@@ -1115,7 +1125,20 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1115,7 +1125,20 @@ export class PlayComponent implements OnInit, OnDestroy {
}, 1000); }, 1000);
} }
} }
} else {
// 错误小鱼的处理逻辑
// 播放错误音效
this.g_cartoon.playAudio('click_wrong');
this.aniOpacity(fish);
// 1秒后恢复鱼的运动
setTimeout(() => {
fish.speed = originalSpeed;
}, 1000);
}
// 对于正确的鱼,显示泡泡破裂动画
if (isCorrect) {
// 按顺序切换序列帧 pao_pao_xu_lie_zhen_1 到 pao_pao_xu_lie_zhen_9 // 按顺序切换序列帧 pao_pao_xu_lie_zhen_1 到 pao_pao_xu_lie_zhen_9
let currentFrame = 1; let currentFrame = 1;
const maxFrame = 9; const maxFrame = 9;
...@@ -1134,9 +1157,38 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1134,9 +1157,38 @@ export class PlayComponent implements OnInit, OnDestroy {
// 开始播放序列帧动画 // 开始播放序列帧动画
playNextFrame(); playNextFrame();
// 正确的鱼不需要恢复运动,因为它们已经被处理了
// 确保鱼保持停止状态
fish.speed = 0;
}
return fish; return fish;
} }
aniOpacity(fish) {
// 使用alphaItem创建平滑的透明度变化动画
const childNames = ['child_image', 'child_paopao_bg']
childNames.forEach(childName => {
// 先变为半透明
alphaItem(fish[childName].ref, 0.5, 0.1, () => {
// 0.5秒后恢复原始透明度,使用0.3秒的动画时间
setTimeout(() => {
alphaItem(fish[childName].ref, 1, 0.1);
setTimeout(() => {
alphaItem(fish[childName].ref, 0.5, 0.1, () => {
// 0.5秒后恢复原始透明度,使用0.1秒的动画时间
setTimeout(() => {
alphaItem(fish[childName].ref, 1, 0.1);
}, 100);
});
}, 100);
}, 100);
});
})
}
/** /**
* 创建临时小鱼并飞向水桶 * 创建临时小鱼并飞向水桶
* @param fish 原始鱼对象 * @param fish 原始鱼对象
......
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