From c114809cc004d6946b6e02330e61d67dbfa7c00d Mon Sep 17 00:00:00 2001 From: walkpan Date: Sun, 29 Mar 2026 21:48:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=B9=B6=E4=BC=98=E5=8C=96=E5=8D=A1=E7=89=8C?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将角色控制器预制体中的节点从 'cb', 'cb-001' 等重命名为 'cb1', 'cb2' 等,以提高可读性和一致性。 - 在 CardComp 中引入固定基准位置逻辑,防止 setSlotPosition 方法在拖动或使用时意外修改 Y 和 Z 轴坐标。 --- assets/resources/gui/role_controller.prefab | 8 ++++---- assets/script/game/map/CardComp.ts | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/assets/resources/gui/role_controller.prefab b/assets/resources/gui/role_controller.prefab index 05e99adf..a28d7ec5 100644 --- a/assets/resources/gui/role_controller.prefab +++ b/assets/resources/gui/role_controller.prefab @@ -5600,7 +5600,7 @@ }, { "__type__": "cc.Node", - "_name": "cb", + "_name": "cb1", "_objFlags": 0, "__editorExtras__": {}, "_parent": { @@ -5876,7 +5876,7 @@ }, { "__type__": "cc.Node", - "_name": "cb-001", + "_name": "cb2", "_objFlags": 0, "__editorExtras__": {}, "_parent": { @@ -6152,7 +6152,7 @@ }, { "__type__": "cc.Node", - "_name": "cb-002", + "_name": "cb3", "_objFlags": 0, "__editorExtras__": {}, "_parent": { @@ -6428,7 +6428,7 @@ }, { "__type__": "cc.Node", - "_name": "cb-003", + "_name": "cb4", "_objFlags": 0, "__editorExtras__": {}, "_parent": { diff --git a/assets/script/game/map/CardComp.ts b/assets/script/game/map/CardComp.ts index 3102a793..f11dbf74 100644 --- a/assets/script/game/map/CardComp.ts +++ b/assets/script/game/map/CardComp.ts @@ -50,6 +50,9 @@ export class CardComp extends CCComp { private isDragging: boolean = false; private isUsing: boolean = false; private restPosition: Vec3 = new Vec3(); + private hasFixedBasePosition: boolean = false; + private fixedBaseY: number = 0; + private fixedBaseZ: number = 0; private opacityComp: UIOpacity | null = null; private cardUseComp: CardUseComp | null = null; private iconVisualToken: number = 0; @@ -228,7 +231,12 @@ export class CardComp extends CCComp { setSlotPosition(x: number) { const current = this.node.position; - this.restPosition = new Vec3(x, current.y, current.z); + if (!this.hasFixedBasePosition) { + this.fixedBaseY = current.y; + this.fixedBaseZ = current.z; + this.hasFixedBasePosition = true; + } + this.restPosition = new Vec3(x, this.fixedBaseY, this.fixedBaseZ); if (!this.isDragging && !this.isUsing) { this.node.setPosition(this.restPosition); }