Commit 945d4497 authored by Tt's avatar Tt

feat(动画): 添加VS对战动画效果并调整资源尺寸

parent 6157230e
...@@ -267,12 +267,15 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -267,12 +267,15 @@ export class PlayComponent implements OnInit, OnDestroy {
// 初始化游戏背景 // 初始化游戏背景
this.initBackground() this.initBackground()
this.initListPage(); // this.initListPage();
this.initFishGame(); // 显示VS动画
this.showVsAni('left');
// this.initFishGame();
// 初始化发音按钮 // 初始化发音按钮
this.initFaYinBtn(); // this.initFaYinBtn();
// 初始化退出按钮 // 初始化退出按钮
// this.initBtnBack(); // this.initBtnBack();
// // 初始化标题 // // 初始化标题
...@@ -370,6 +373,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -370,6 +373,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(jiaoshiElement.ref, zIndexMap.background + 1) this.render(jiaoshiElement.ref, zIndexMap.background + 1)
} }
/** /**
* 初始化列表页面 * 初始化列表页面
* 创建一个可滑动的列表页面,包含多个子节点 * 创建一个可滑动的列表页面,包含多个子节点
...@@ -786,46 +790,143 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -786,46 +790,143 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
} }
/**
* 初始化VS视图,创建所有VS动画相关的元素
*/
initVsView() { initVsView() {
// 左侧节点:hong_se_jian_bian、ju_mao_tou、v // 创建红色渐变面板 - 初始位置在屏幕左侧外
const leftNodes = [, 'ju_mao_tou', 'v'];
// 右侧节点:lan_se_jian_bian、s、hui_mao_tou
const rightNodes = ['lan_se_jian_bian', 's', 'hui_mao_tou'];
const hong_se_jian_bian = this.g_cartoon.createCartoonElement('hong_se_jian_bian', 'MySprite'); const hong_se_jian_bian = this.g_cartoon.createCartoonElement('hong_se_jian_bian', 'MySprite');
hong_se_jian_bian.ref.init(this.g_cartoon.images.get('hong_se_jian_bian')); hong_se_jian_bian.ref.init(this.g_cartoon.images.get('hong_se_jian_bian'));
hong_se_jian_bian.ref.scaleX = this.g_mapScale; hong_se_jian_bian.ref.scaleX = this.g_mapScale;
hong_se_jian_bian.ref.scaleY = this.g_mapScale; hong_se_jian_bian.ref.scaleY = this.g_mapScale;
hong_se_jian_bian.ref.x = 0; hong_se_jian_bian.ref.x = -400 * this.g_mapScale; // 初始位置在屏幕左侧外
hong_se_jian_bian.ref.y = this.g_canvasHeight / 2; hong_se_jian_bian.ref.y = this.g_canvasHeight / 2;
this.render(hong_se_jian_bian.ref, zIndexMap.card); this.render(hong_se_jian_bian.ref, zIndexMap.card);
// 创建蓝色渐变面板 - 初始位置在屏幕右侧外
const lan_se_jian_bian = this.g_cartoon.createCartoonElement('lan_se_jian_bian', 'MySprite'); const lan_se_jian_bian = this.g_cartoon.createCartoonElement('lan_se_jian_bian', 'MySprite');
lan_se_jian_bian.ref.init(this.g_cartoon.images.get('lan_se_jian_bian')); lan_se_jian_bian.ref.init(this.g_cartoon.images.get('lan_se_jian_bian'));
lan_se_jian_bian.ref.scaleX = this.g_mapScale; lan_se_jian_bian.ref.scaleX = this.g_mapScale;
lan_se_jian_bian.ref.scaleY = this.g_mapScale; lan_se_jian_bian.ref.scaleY = this.g_mapScale;
lan_se_jian_bian.ref.x = 0; lan_se_jian_bian.ref.x = this.g_canvasWidth + 400 * this.g_mapScale; // 初始位置在屏幕右侧外
lan_se_jian_bian.ref.y = 0; lan_se_jian_bian.ref.y = this.g_canvasHeight / 2;
this.render(lan_se_jian_bian.ref, zIndexMap.card); this.render(lan_se_jian_bian.ref, zIndexMap.card);
const v_element = this.g_cartoon.createCartoonElement('v', 'MySprite');
// // 创建右侧节点 v_element.ref.init(this.g_cartoon.images.get('v'));
// rightNodes.forEach((nodeName, index) => { v_element.ref.scaleX = this.g_mapScale;
// const element = this.g_cartoon.createCartoonElement(nodeName, 'MySprite'); v_element.ref.scaleY = this.g_mapScale;
// element.ref.init(this.g_cartoon.images.get(nodeName)); v_element.ref.x = this.g_canvasWidth / 2 - 20 * this.g_mapScale;
v_element.ref.y = this.g_canvasHeight / 2;
// // 应用屏幕适配缩放 this.render(v_element.ref, zIndexMap.card + 2);
// element.ref.scaleX = this.g_mapScale;
// element.ref.scaleY = this.g_mapScale; const s_element = this.g_cartoon.createCartoonElement('s', 'MySprite');
s_element.ref.init(this.g_cartoon.images.get('s'));
// // 设置右侧位置(画布右侧3/4处) s_element.ref.scaleX = this.g_mapScale;
// element.ref.x = this.g_canvasWidth * 0.75; s_element.ref.scaleY = this.g_mapScale;
// element.ref.y = this.g_canvasHeight * 0.3 + (index * 150 * this.g_mapScale); s_element.ref.x = this.g_canvasWidth / 2 + 20 * this.g_mapScale;
s_element.ref.y = this.g_canvasHeight / 2;
// // 渲染元素 this.render(s_element.ref, zIndexMap.card + 2);
// this.render(element.ref, zIndexMap.card);
// }); // 创建其他VS动画元素
// 左侧元素:橘猫头和V
const ju_mao_tou = this.g_cartoon.createCartoonElement('ju_mao_tou', 'MySprite');
ju_mao_tou.ref.init(this.g_cartoon.images.get('ju_mao_tou'));
ju_mao_tou.ref.scaleX = this.g_mapScale;
ju_mao_tou.ref.scaleY = this.g_mapScale;
ju_mao_tou.ref.x = this.g_canvasWidth / 4;
ju_mao_tou.ref.y = this.g_canvasHeight / 2;
this.render(ju_mao_tou.ref, zIndexMap.card + 1);
// 右侧元素:灰猫头和S
const hui_mao_tou = this.g_cartoon.createCartoonElement('hui_mao_tou', 'MySprite');
hui_mao_tou.ref.init(this.g_cartoon.images.get('hui_mao_tou'));
hui_mao_tou.ref.scaleX = this.g_mapScale;
hui_mao_tou.ref.scaleY = this.g_mapScale;
hui_mao_tou.ref.x = this.g_canvasWidth * 3 / 4;
hui_mao_tou.ref.y = this.g_canvasHeight / 2;
this.render(hui_mao_tou.ref, zIndexMap.card + 1);
// 播放VS音效
this.g_cartoon.playAudio('vs');
}
/**
* 显示VS动画
* @param type 动画类型,'left' 或 'right'
*/
showVsAni(type: string) {
// 初始化VS视图
this.initVsView();
// 获取红色和蓝色渐变面板元素
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 hongTargetX = this.g_canvasWidth / 2 - 350 * this.g_mapScale;
// 设置蓝色渐变面板的目标位置
const lanTargetX = this.g_canvasWidth / 2 + 340 * this.g_mapScale;
// 使用moveItem函数实现红色渐变面板从左侧移动到目标位置的动画,速度改为0.3秒
moveItem(hong_se_jian_bian, hongTargetX, hong_se_jian_bian.y, 0.3);
// 使用moveItem函数实现蓝色渐变面板从右侧移动到目标位置的动画,速度改为0.3秒
moveItem(lan_se_jian_bian, lanTargetX, lan_se_jian_bian.y, 0.3);
// 获取VS元素
const v_element = this.g_cartoon.cartoonElementsBuffer['v'].ref;
const s_element = this.g_cartoon.cartoonElementsBuffer['s'].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;
// 设置VS元素的初始位置(屏幕外)
v_element.x = -100 * this.g_mapScale; // V元素初始位置在屏幕左侧外
s_element.x = this.g_canvasWidth + 100 * this.g_mapScale; // S元素初始位置在屏幕右侧外
// 0.2秒后执行VS元素的动画
setTimeout(() => {
// 使用moveItem函数实现V元素从屏幕外移动到目标位置的动画,速度为0.2秒
moveItem(v_element, this.g_canvasWidth / 2 - 20 * this.g_mapScale, v_element.y, 0.2);
// 使用moveItem函数实现S元素从屏幕外移动到目标位置的动画,速度为0.2秒
moveItem(s_element, this.g_canvasWidth / 2 + 20 * this.g_mapScale, s_element.y, 0.2);
// 根据类型设置不同的动画效果
if (type === 'left') {
// 左侧胜利的动画效果 - 橘猫头放大效果
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);
} else if (type === 'right') {
// 右侧胜利的动画效果 - 灰猫头放大效果
hui_mao_tou.scaleX = hui_mao_tou.scaleY = this.g_mapScale * 0.8;
tweenChange(hui_mao_tou, {scaleX: this.g_mapScale * 1.2, scaleY: this.g_mapScale * 1.2}, 0.3);
}
}, 200);
// 3秒后隐藏所有VS相关元素
setTimeout(() => {
// 隐藏红色渐变面板
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;
}
});
}, 3000);
} }
createCat(type) { createCat(type) {
......
...@@ -178,15 +178,15 @@ const localImagesSize = { ...@@ -178,15 +178,15 @@ const localImagesSize = {
'yu_xiang_zi': { width: 67, height: 53 }, 'yu_xiang_zi': { width: 67, height: 53 },
// VS动画 // VS动画
'dao_ji_shi_1': { width: 163, height: 242 }, 'dao_ji_shi_1': { width: 163 * 0.6, height: 242 * 0.6 },
'dao_ji_shi_2': { width: 163, height: 242 }, 'dao_ji_shi_2': { width: 163 * 0.6, height: 242 * 0.6 },
'dao_ji_shi_3': { width: 163, height: 242 }, 'dao_ji_shi_3': { width: 163 * 0.6, height: 242 * 0.6 },
'hong_se_jian_bian': { width: 1393, height: 622 }, 'hong_se_jian_bian': { width: 1393 * 0.6, height: 622 * 0.6 },
'hui_mao_tou': { width: 501, height: 409 }, 'lan_se_jian_bian': { width: 1400 * 0.6, height: 620 * 0.6 },
'ju_mao_tou': { width: 460, height: 409 }, 'hui_mao_tou': { width: 501 * 0.6, height: 409 * 0.6 },
'lan_se_jian_bian': { width: 1400, height: 620 }, 'ju_mao_tou': { width: 460 * 0.6, height: 409 * 0.6 },
's': { width: 221, height: 444 }, 's': { width: 221 * 0.6, height: 444 * 0.6 },
'v': { width: 210, height: 446 }, 'v': { width: 210 * 0.6, height: 446 * 0.6 },
// 灰猫招手动画 // 灰猫招手动画
'hui_mao_zhao_shou_1': { width: 109, height: 91 }, 'hui_mao_zhao_shou_1': { width: 109, height: 91 },
...@@ -231,4 +231,4 @@ const localImagesSize = { ...@@ -231,4 +231,4 @@ const localImagesSize = {
'shui_di_dong_hua_11': { width: 106, height: 102 } 'shui_di_dong_hua_11': { width: 106, height: 102 }
}; };
export {localImages, localAudios, localImagesSize}; export { localImages, localAudios, localImagesSize };
src/assets/game/ani/VS_dong_hua_1/v.png

10.8 KB | W: | H:

src/assets/game/ani/VS_dong_hua_1/v.png

5.72 KB | W: | H:

src/assets/game/ani/VS_dong_hua_1/v.png
src/assets/game/ani/VS_dong_hua_1/v.png
src/assets/game/ani/VS_dong_hua_1/v.png
src/assets/game/ani/VS_dong_hua_1/v.png
  • 2-up
  • Swipe
  • Onion skin
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