From 741da016fd13a465bb9c9fbdf98fa3144b647f66 Mon Sep 17 00:00:00 2001 From: panfudan Date: Thu, 12 Jun 2025 20:39:32 +0800 Subject: [PATCH] =?UTF-8?q?card=20=E6=98=BE=E7=A4=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/script/game/map/CardsComp.ts | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/assets/script/game/map/CardsComp.ts b/assets/script/game/map/CardsComp.ts index eba9417c..3793daef 100644 --- a/assets/script/game/map/CardsComp.ts +++ b/assets/script/game/map/CardsComp.ts @@ -1,4 +1,4 @@ -import { _decorator, v3 } from "cc"; +import { _decorator, tween, v3 } from "cc"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { GameEvent } from "../common/config/GameEvent"; @@ -64,13 +64,29 @@ export class CardsCompComp extends CCComp { } show(e:GameEvent,data:any){ - this.node.setPosition(v3(0,640,0)) - // console.log("cards show",e,this.node.position) + // 设置初始状态 + this.node.setPosition(v3(0, 0, 0)); + this.node.setScale(v3(0, 0, 1)); + + // 使用缓动动画放大和移动 + tween(this.node) + .parallel( + tween().to(0.3, { scale: v3(1, 1, 1) }, { easing: 'backOut' }), + tween().to(0.3, { position: v3(0, 640, 0) }, { easing: 'backOut' }) + ) + .start(); } hide(e:GameEvent,data:any){ - this.node.setPosition(v3(0,-1000,0)) - // console.log("cards hide",e,this.node.position) + tween(this.node) + .parallel( + tween().to(0.3, { scale: v3(0, 0, 1) }, { easing: 'backIn' }), + tween().to(0.3, { position: v3(0, 0, 0) }, { easing: 'backIn' }) + ) + .call(()=>{ + this.node.setPosition(v3(0, -1000, 0)); + }) + .start(); } /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */