Commit da018b33 authored by Tt's avatar Tt

feat(play): 添加泡泡破裂动画效果并优化鱼类创建逻辑

parent 7928d53e
......@@ -697,7 +697,8 @@ export class PlayComponent implements OnInit, OnDestroy {
const type = 'big'
const data = this.g_formData.questions[0];
this.createFish(type, data);
const fish = this.createFish(type, data);
const paopao = this.brokePaopao(fish);
}
initVsView() {
......@@ -891,6 +892,14 @@ export class PlayComponent implements OnInit, OnDestroy {
pao_pao_da_png.ref.y = -38
fish.ref.addChild(pao_pao_da_png.ref);
// 创建船节点 - 作为钓鱼台,放在最下方
const pao_pao_po_ani = this.g_cartoon.createCartoonElement('pao_pao_po_ani', 'MySprite');
pao_pao_po_ani.ref.init(this.g_cartoon.images.get('pao_pao_xu_lie_zhen_1'));
pao_pao_po_ani.ref.scaleX = this.g_mapScale;
pao_pao_po_ani.ref.scaleY = this.g_mapScale;
pao_pao_po_ani.ref.x = 0
pao_pao_po_ani.ref.y = -48
fish.ref.addChild(pao_pao_po_ani.ref);
// 一条小鱼
const colors = ['huang', 'ju', 'lan', 'lv']
const nameYu = colors[Math.floor(Math.random() * colors.length)] + '_yu'
......@@ -901,6 +910,7 @@ export class PlayComponent implements OnInit, OnDestroy {
xiao_yu.ref.x = 40 * this.g_mapScale;
xiao_yu.ref.y = 80 * this.g_mapScale;
fish.ref.addChild(xiao_yu.ref);
fish['child_xiao_yu'] = xiao_yu;
// 网络加载的图片
......@@ -924,6 +934,7 @@ export class PlayComponent implements OnInit, OnDestroy {
})
// 将图片元素添加到itemNode
fish.ref.addChild(imageElement.ref);
fish['child_image'] = imageElement
}
if (type == 'big') {
fish.ref.scaleX = this.g_mapScale * 1.5;
......@@ -933,6 +944,35 @@ export class PlayComponent implements OnInit, OnDestroy {
fish.ref.scaleY = this.g_mapScale;
}
this.render(fish.ref, zIndexMap.card);
fish['child_paopao_bg'] = pao_pao_da_png;
fish['child_paopao_ani'] = pao_pao_po_ani;
return fish;
}
brokePaopao(fish) {
fish['child_paopao_bg'].ref.visible = false;
fish['child_xiao_yu'].ref.visible = false;
fish['child_image'].ref.visible = false;
fish['child_paopao_ani'].ref.visible = true;
// 按顺序切换序列帧 pao_pao_xu_lie_zhen_1 到 pao_pao_xu_lie_zhen_9
let currentFrame = 1;
const maxFrame = 9;
const frameInterval = 100; // 每帧间隔时间,可以根据需要调整
const playNextFrame = () => {
if (currentFrame <= maxFrame) {
// 设置当前帧的图像
fish['child_paopao_ani'].ref.init(this.g_cartoon.images.get(`pao_pao_xu_lie_zhen_${currentFrame}`));
currentFrame++;
// 设置下一帧的定时器
setTimeout(playNextFrame, frameInterval);
}
};
// 开始播放序列帧动画
playNextFrame();
return 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