Commit 7f337bd1 authored by Tt's avatar Tt

feat(动画效果): 添加鱼雨动画后的猫咪挥手动画和光束效果

parent 04e46b95
......@@ -858,6 +858,10 @@ export class PlayComponent implements OnInit, OnDestroy {
this.updateCat();
this.startNextQuestion();
setTimeout(() => {
this.showFishRain('center');
}, 500);
}
nextBattle(playTime) {
......@@ -1686,6 +1690,17 @@ export class PlayComponent implements OnInit, OnDestroy {
break;
}
// 创建光束元素
const guangShu = this.g_cartoon.createCartoonElement('guang_shu', 'MySprite');
guangShu.ref.init(this.g_cartoon.images.get('guang_shu'));
guangShu.ref.scaleX = this.g_mapScale;
guangShu.ref.scaleY = this.g_mapScale;
guangShu.ref.x = fishX;
guangShu.ref.y = 245 * this.g_mapScale;
guangShu.ref.alpha = 0;
this.render(guangShu.ref, zIndexMap.cat + 9); // 在鱼后面
alphaItem(guangShu.ref, 1, 1); // 0.5秒内透明度变为1
// 创建鱼元素
const fishRain = this.g_cartoon.createCartoonElement('fish_rain', 'MySprite');
fishRain.ref.init(this.g_cartoon.images.get('yu_00')); // 初始帧
......@@ -1719,12 +1734,48 @@ export class PlayComponent implements OnInit, OnDestroy {
const timeoutId = setTimeout(playNextFrame, frameInterval);
this.m_setTimeoutIDs.push(timeoutId);
} else {
// 动画播放完成后隐藏鱼元素
// 显示游戏结束提示
setTimeout(() => {
console.log("游戏结束!");
fishRain.ref.visible = false;
}, 200);
// 动画播放完成后开始播放猫咪挥手动画
// fishRain.ref.visible = false;
// 创建猫咪元素
const catWave = this.g_cartoon.createCartoonElement('cat_wave', 'MySprite');
// 根据位置类型选择不同的动画序列
const isRightSide = type === 'right';
const maxFrame = !isRightSide ? 6 : 8;
let currentCatFrame = 1;
const catFrameInterval = 100; // 每帧间隔时间
// 设置猫咪位置和缩放
catWave.ref.scaleX = this.g_mapScale;
catWave.ref.scaleY = this.g_mapScale;
catWave.ref.x = fishX;
catWave.ref.y = 525 * this.g_mapScale;
// 渲染猫咪元素,确保在光束和鱼之间
this.render(catWave.ref, zIndexMap.cat + 9.5);
// 创建猫咪帧动画函数
const playCatAnimation = () => {
if (currentCatFrame <= maxFrame) {
// 根据位置选择对应的动画序列
const prefix = !isRightSide ? 'ju_mao_zhao_shou_' : 'hui_mao_zhao_shou_';
catWave.ref.init(this.g_cartoon.images.get(`${prefix}${currentCatFrame}`));
// 递增帧索引
currentCatFrame++;
// 设置下一帧的定时器
const timeoutId = setTimeout(playCatAnimation, catFrameInterval);
this.m_setTimeoutIDs.push(timeoutId);
if (currentCatFrame > maxFrame) {
currentCatFrame = 0;
}
}
};
// 开始播放猫咪动画
playCatAnimation();
}
};
......
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