Commit 04ee86bd authored by Tt's avatar Tt

动画阶段1

parent 945d4497
...@@ -185,6 +185,32 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -185,6 +185,32 @@ export class PlayComponent implements OnInit, OnDestroy {
this.restartGame() this.restartGame()
} }
/**
* 隐藏所有VS相关元素
*/
hideVsElements() {
// 隐藏红色渐变面板
const hong_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['hong_se_jian_bian'];
if (hong_se_jian_bian && hong_se_jian_bian.ref) {
hong_se_jian_bian.ref.visible = false;
}
// 隐藏蓝色渐变面板
const lan_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['lan_se_jian_bian'];
if (lan_se_jian_bian && lan_se_jian_bian.ref) {
lan_se_jian_bian.ref.visible = false;
}
// 隐藏其他VS元素
const vsElements = ['v', 's', 'ju_mao_tou', 'hui_mao_tou'];
vsElements.forEach(elementName => {
const element = this.g_cartoon.cartoonElementsBuffer[elementName];
if (element && element.ref) {
element.ref.visible = false;
}
});
}
/** /**
* 映射预加载图片[网络]资源 * 映射预加载图片[网络]资源
* 从内容对象中提取所有图片URL,用于预加载 * 从内容对象中提取所有图片URL,用于预加载
...@@ -827,7 +853,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -827,7 +853,7 @@ export class PlayComponent implements OnInit, OnDestroy {
s_element.ref.x = this.g_canvasWidth / 2 + 20 * this.g_mapScale; s_element.ref.x = this.g_canvasWidth / 2 + 20 * this.g_mapScale;
s_element.ref.y = this.g_canvasHeight / 2; s_element.ref.y = this.g_canvasHeight / 2;
this.render(s_element.ref, zIndexMap.card + 2); this.render(s_element.ref, zIndexMap.card + 2);
// 创建其他VS动画元素 // 创建其他VS动画元素
// 左侧元素:橘猫头和V // 左侧元素:橘猫头和V
const ju_mao_tou = this.g_cartoon.createCartoonElement('ju_mao_tou', 'MySprite'); const ju_mao_tou = this.g_cartoon.createCartoonElement('ju_mao_tou', 'MySprite');
...@@ -850,74 +876,193 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -850,74 +876,193 @@ export class PlayComponent implements OnInit, OnDestroy {
// 播放VS音效 // 播放VS音效
this.g_cartoon.playAudio('vs'); this.g_cartoon.playAudio('vs');
} }
/** /**
* 显示VS动画 * 显示VS动画
* @param type 动画类型,'left' 或 'right' * @param type 动画类型,'left' 或 'right'
*/ */
showVsAni(type: string) { showVsAni(type: string) {
// 动画配置参数
const config = {
// 面板动画配置
panel: {
// 红色面板配置
hong: {
offsetX: 350, // 红色面板X轴偏移量
initialOffsetX: -400, // 红色面板初始X轴偏移量(屏幕外)
moveTime: 0.3, // 移动动画时间
scaleRatio: 1.5, // 放大比例
moveDistance: 40 // 移动距离
},
// 蓝色面板配置
lan: {
offsetX: 340, // 蓝色面板X轴偏移量
initialOffsetX: 400, // 蓝色面板初始X轴偏移量(屏幕外)
moveTime: 0.3, // 移动动画时间
scaleRatio: 1.5, // 放大比例
moveDistance: 130 // 移动距离
}
},
// VS元素动画配置
vs: {
// V元素配置
v: {
offsetX: 20, // V元素X轴偏移量
initialOffsetX: -100, // V元素初始X轴偏移量(屏幕外)
moveTime: 0.2 // 移动动画时间
},
// S元素配置
s: {
offsetX: 20, // S元素X轴偏移量
initialOffsetX: 100, // S元素初始X轴偏移量(屏幕外)
moveTime: 0.2 // 移动动画时间
}
},
// 猫猫头动画配置
cat: {
// 橘猫头配置
ju: {
scaleRatio: 1.5, // 放大比例
shrinkRatio: 0.8, // 缩小比例
moveDistance: 20, // 移动距离
animTime: 0.3 // 动画时间
},
// 灰猫头配置
hui: {
scaleRatio: 1.5, // 放大比例
shrinkRatio: 0.8, // 缩小比例
moveDistance: 20, // 移动距离
animTime: 0.3 // 动画时间
}
},
// 通用配置
common: {
vsAnimDelay: 200, // VS元素动画延迟时间
hideDelay: 3000 // 隐藏元素延迟时间
}
};
// 初始化VS视图 // 初始化VS视图
this.initVsView(); this.initVsView();
// 获取红色和蓝色渐变面板元素 // 获取红色和蓝色渐变面板元素
const hong_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['hong_se_jian_bian'].ref; const hong_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['hong_se_jian_bian'].ref;
const lan_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['lan_se_jian_bian'].ref; const lan_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['lan_se_jian_bian'].ref;
// 设置红色渐变面板的目标位置 // 设置红色渐变面板的目标位置
const hongTargetX = this.g_canvasWidth / 2 - 350 * this.g_mapScale; const hongTargetX = this.g_canvasWidth / 2 - config.panel.hong.offsetX * this.g_mapScale;
// 设置蓝色渐变面板的目标位置 // 设置蓝色渐变面板的目标位置
const lanTargetX = this.g_canvasWidth / 2 + 340 * this.g_mapScale; const lanTargetX = this.g_canvasWidth / 2 + config.panel.lan.offsetX * this.g_mapScale;
// 使用moveItem函数实现红色渐变面板从左侧移动到目标位置的动画,速度改为0.3秒 // 使用moveItem函数实现红色渐变面板从左侧移动到目标位置的动画
moveItem(hong_se_jian_bian, hongTargetX, hong_se_jian_bian.y, 0.3); moveItem(hong_se_jian_bian, hongTargetX, hong_se_jian_bian.y, config.panel.hong.moveTime);
// 使用moveItem函数实现蓝色渐变面板从右侧移动到目标位置的动画,速度改为0.3秒 // 使用moveItem函数实现蓝色渐变面板从右侧移动到目标位置的动画
moveItem(lan_se_jian_bian, lanTargetX, lan_se_jian_bian.y, 0.3); moveItem(lan_se_jian_bian, lanTargetX, lan_se_jian_bian.y, config.panel.lan.moveTime);
// 获取VS元素 // 获取VS元素
const v_element = this.g_cartoon.cartoonElementsBuffer['v'].ref; const v_element = this.g_cartoon.cartoonElementsBuffer['v'].ref;
const s_element = this.g_cartoon.cartoonElementsBuffer['s'].ref; const s_element = this.g_cartoon.cartoonElementsBuffer['s'].ref;
const ju_mao_tou = this.g_cartoon.cartoonElementsBuffer['ju_mao_tou'].ref; const ju_mao_tou = this.g_cartoon.cartoonElementsBuffer['ju_mao_tou'].ref;
const hui_mao_tou = this.g_cartoon.cartoonElementsBuffer['hui_mao_tou'].ref; const hui_mao_tou = this.g_cartoon.cartoonElementsBuffer['hui_mao_tou'].ref;
// 设置VS元素的初始位置(屏幕外) // 设置VS元素的初始位置(屏幕外)
v_element.x = -100 * this.g_mapScale; // V元素初始位置在屏幕左侧外 v_element.x = config.vs.v.initialOffsetX * this.g_mapScale; // V元素初始位置在屏幕左侧外
s_element.x = this.g_canvasWidth + 100 * this.g_mapScale; // S元素初始位置在屏幕右侧外 s_element.x = this.g_canvasWidth + config.vs.s.initialOffsetX * this.g_mapScale; // S元素初始位置在屏幕右侧外
// 0.2秒后执行VS元素的动画 // VS元素动画延迟执行
setTimeout(() => { setTimeout(() => {
// 使用moveItem函数实现V元素从屏幕外移动到目标位置的动画,速度为0.2秒 // 使用moveItem函数实现V元素从屏幕外移动到目标位置的动画
moveItem(v_element, this.g_canvasWidth / 2 - 20 * this.g_mapScale, v_element.y, 0.2); moveItem(v_element, this.g_canvasWidth / 2 - config.vs.v.offsetX * this.g_mapScale, v_element.y, config.vs.v.moveTime);
// 使用moveItem函数实现S元素从屏幕外移动到目标位置的动画,速度为0.2秒 // 使用moveItem函数实现S元素从屏幕外移动到目标位置的动画
moveItem(s_element, this.g_canvasWidth / 2 + 20 * this.g_mapScale, s_element.y, 0.2); moveItem(s_element, this.g_canvasWidth / 2 + config.vs.s.offsetX * this.g_mapScale, s_element.y, config.vs.s.moveTime);
setTimeout(() => {
// 根据类型设置不同的动画效果 // 隐藏VS元素
if (type === 'left') { v_element.visible = false;
// 左侧胜利的动画效果 - 橘猫头放大效果 s_element.visible = false;
ju_mao_tou.scaleX = ju_mao_tou.scaleY = this.g_mapScale * 0.8; // 根据类型设置不同的动画效果
tweenChange(ju_mao_tou, {scaleX: this.g_mapScale * 1.2, scaleY: this.g_mapScale * 1.2}, 0.3); if (type === 'left') {
} else if (type === 'right') { // 左侧胜利的动画效果 - 左侧猫猫头和红色面板放大,右侧猫猫头缩小并向右移动,蓝色底板向右移动
// 右侧胜利的动画效果 - 灰猫头放大效果 // 左侧猫猫头放大
hui_mao_tou.scaleX = hui_mao_tou.scaleY = this.g_mapScale * 0.8; ju_mao_tou.scaleX = ju_mao_tou.scaleY = this.g_mapScale;
tweenChange(hui_mao_tou, {scaleX: this.g_mapScale * 1.2, scaleY: this.g_mapScale * 1.2}, 0.3); tweenChange(ju_mao_tou, {
} scaleX: this.g_mapScale * config.cat.ju.scaleRatio,
}, 200); scaleY: this.g_mapScale * config.cat.ju.scaleRatio
}, config.cat.ju.animTime);
// 3秒后隐藏所有VS相关元素 // 红色面板放大
const hong_se_jian_bian_ref = this.g_cartoon.cartoonElementsBuffer['hong_se_jian_bian'].ref;
tweenChange(hong_se_jian_bian_ref, {
scaleX: this.g_mapScale * config.panel.hong.scaleRatio,
scaleY: this.g_mapScale * config.panel.hong.scaleRatio
}, config.panel.hong.moveTime);
// 右侧猫猫头缩小并向右移动
hui_mao_tou.scaleX = hui_mao_tou.scaleY = this.g_mapScale;
tweenChange(hui_mao_tou, {
scaleX: this.g_mapScale * config.cat.hui.shrinkRatio,
scaleY: this.g_mapScale * config.cat.hui.shrinkRatio,
x: hui_mao_tou.x + config.cat.hui.moveDistance * this.g_mapScale,
y: hui_mao_tou.y + 95 * this.g_mapScale
}, config.cat.hui.animTime);
// 蓝色底板向右移动
const lan_se_jian_bian_ref = this.g_cartoon.cartoonElementsBuffer['lan_se_jian_bian'].ref;
moveItem(
lan_se_jian_bian_ref,
lan_se_jian_bian_ref.x + config.panel.lan.moveDistance * this.g_mapScale,
lan_se_jian_bian_ref.y + 95 * this.g_mapScale,
config.panel.lan.moveTime
);
} else if (type === 'right') {
// 右侧胜利的动画效果 - 右侧猫猫头和蓝色面板放大,左侧猫猫头缩小并向左移动,红色底板向左移动
// 右侧猫猫头放大
hui_mao_tou.scaleX = hui_mao_tou.scaleY = this.g_mapScale;
tweenChange(hui_mao_tou, {
scaleX: this.g_mapScale * config.cat.hui.scaleRatio,
scaleY: this.g_mapScale * config.cat.hui.scaleRatio
}, config.cat.hui.animTime);
// 蓝色面板放大
const lan_se_jian_bian_ref = this.g_cartoon.cartoonElementsBuffer['lan_se_jian_bian'].ref;
tweenChange(lan_se_jian_bian_ref, {
scaleX: this.g_mapScale * config.panel.lan.scaleRatio,
scaleY: this.g_mapScale * config.panel.lan.scaleRatio
}, config.panel.lan.moveTime);
// 左侧猫猫头缩小并向左移动
ju_mao_tou.scaleX = ju_mao_tou.scaleY = this.g_mapScale;
tweenChange(ju_mao_tou, {
scaleX: this.g_mapScale * config.cat.ju.shrinkRatio,
scaleY: this.g_mapScale * config.cat.ju.shrinkRatio,
x: ju_mao_tou.x - config.cat.ju.moveDistance * this.g_mapScale
}, config.cat.ju.animTime);
// 红色底板向左移动
const hong_se_jian_bian_ref = this.g_cartoon.cartoonElementsBuffer['hong_se_jian_bian'].ref;
moveItem(
hong_se_jian_bian_ref,
hong_se_jian_bian_ref.x - config.panel.hong.moveDistance * this.g_mapScale,
hong_se_jian_bian_ref.y,
config.panel.hong.moveTime
);
}
}, config.vs.v.moveTime * 1000 + 500);
}, config.common.vsAnimDelay);
// 隐藏所有VS相关元素
setTimeout(() => { setTimeout(() => {
// 隐藏红色渐变面板 // 隐藏红色渐变面板
const hong_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['hong_se_jian_bian']; const hong_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['hong_se_jian_bian'];
if (hong_se_jian_bian && hong_se_jian_bian.ref) { if (hong_se_jian_bian && hong_se_jian_bian.ref) {
hong_se_jian_bian.ref.visible = false; hong_se_jian_bian.ref.visible = false;
} }
// 隐藏蓝色渐变面板 // 隐藏蓝色渐变面板
const lan_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['lan_se_jian_bian']; const lan_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['lan_se_jian_bian'];
if (lan_se_jian_bian && lan_se_jian_bian.ref) { if (lan_se_jian_bian && lan_se_jian_bian.ref) {
lan_se_jian_bian.ref.visible = false; lan_se_jian_bian.ref.visible = false;
} }
// 隐藏其他VS元素 // 隐藏其他VS元素
const vsElements = ['v', 's', 'ju_mao_tou', 'hui_mao_tou']; const vsElements = ['v', 's', 'ju_mao_tou', 'hui_mao_tou'];
vsElements.forEach(elementName => { vsElements.forEach(elementName => {
...@@ -926,7 +1071,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -926,7 +1071,7 @@ export class PlayComponent implements OnInit, OnDestroy {
element.ref.visible = false; element.ref.visible = false;
} }
}); });
}, 3000); }, config.common.hideDelay);
} }
createCat(type) { createCat(type) {
......
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