refactor: 重命名节点并优化卡牌位置计算

- 将角色控制器预制体中的节点从 'cb', 'cb-001' 等重命名为 'cb1', 'cb2' 等,以提高可读性和一致性。
- 在 CardComp 中引入固定基准位置逻辑,防止 setSlotPosition 方法在拖动或使用时意外修改 Y 和 Z 轴坐标。
This commit is contained in:
walkpan
2026-03-29 21:48:31 +08:00
parent d6c2ba6534
commit c114809cc0
2 changed files with 13 additions and 5 deletions

View File

@@ -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);
}