fix(equipBox): 修正装备弹窗显示层级和位置问题

1. 调整ibox预制体的尺寸和对齐参数适配新布局
2. 修改弹窗挂载层级,避免被其他元素遮挡
3. 修正弹窗位置计算逻辑,适配新的父节点坐标系
This commit is contained in:
pan
2026-08-06 19:51:26 +08:00
parent 0b579f695c
commit c78502c4ff
2 changed files with 23 additions and 14 deletions

View File

@@ -786,7 +786,7 @@
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 2.5, "x": 0,
"y": 0, "y": 0,
"z": 0 "z": 0
}, },
@@ -827,8 +827,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 715, "width": 720,
"height": 120 "height": 200
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -900,10 +900,10 @@
}, },
"_alignFlags": 45, "_alignFlags": 45,
"_target": null, "_target": null,
"_left": 5, "_left": 0,
"_right": 0, "_right": 0,
"_top": 0, "_top": 540,
"_bottom": 0, "_bottom": 540,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
"_isAbsLeft": true, "_isAbsLeft": true,
@@ -1079,7 +1079,7 @@
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 720, "width": 720,
"height": 120 "height": 1280
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",

View File

@@ -31,7 +31,7 @@
* - smc.mission —— 游戏运行状态 * - smc.mission —— 游戏运行状态
*/ */
import { mLogger } from "../common/Logger"; import { mLogger } from "../common/Logger";
import { _decorator, Node, Prefab, Sprite, Label, Vec3, instantiate, tween, v3, Tween, NodeEventType } from "cc"; import { _decorator, Node, Prefab, Sprite, Label, Vec3, instantiate, tween, v3, Tween, NodeEventType, UITransform } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { CardTriggerType } from "../common/config/CardSet"; import { CardTriggerType } from "../common/config/CardSet";
@@ -198,16 +198,25 @@ export class EquipBoxComp extends CCComp {
oops.audio.playEffect("music/button"); oops.audio.playEffect("music/button");
this.iboxNode = instantiate(this.iboxPrefab); this.iboxNode = instantiate(this.iboxPrefab);
// 挂到装备图标的父节点下,使用局部坐标系 // 挂到 ebars_node 的父级(再上移一层),确保 IBox 渲染在装备槽整个区域之上不被遮挡;
const parent = this.node.parent; // 坐标换算到该容器坐标系,使 IBox 出现在装备正上方
parent?.addChild(this.iboxNode); const ebar = this.node.parent;
// 弹窗宽度 720X 居中为 0Y 相对图标向上偏移 const ebarsNode = ebar?.parent;
this.iboxNode.setPosition(0, this.node.position.y + EquipBoxComp.IBOX_OFFSET_Y, this.node.position.z); const container = ebarsNode?.parent ?? ebarsNode ?? ebar;
container?.addChild(this.iboxNode);
// 弹窗宽度 720X 居中为 0Y 相对装备向上偏移(换算到 container 坐标系)
let localY = this.node.position.y + EquipBoxComp.IBOX_OFFSET_Y;
if (container && ebar && container !== ebar) {
const worldPos = this.node.getWorldPosition(new Vec3());
const localPos = container.getComponent(UITransform)!.convertToNodeSpaceAR(worldPos);
localY = localPos.y + EquipBoxComp.IBOX_OFFSET_Y;
}
this.iboxNode.setPosition(0, localY, this.node.position.z);
mLogger.log(this.debugMode, "EquipBoxComp", "ibox instantiated", { mLogger.log(this.debugMode, "EquipBoxComp", "ibox instantiated", {
iboxNodeValid: this.iboxNode?.isValid, iboxNodeValid: this.iboxNode?.isValid,
iboxNodeActive: this.iboxNode?.active, iboxNodeActive: this.iboxNode?.active,
iboxNodePos: this.iboxNode?.position, iboxNodePos: this.iboxNode?.position,
parentName: parent?.name, parentName: container?.name,
}); });
const ibox = this.iboxNode.getComponent(IBoxComp); const ibox = this.iboxNode.getComponent(IBoxComp);
mLogger.log(this.debugMode, "EquipBoxComp", "ibox component", { mLogger.log(this.debugMode, "EquipBoxComp", "ibox component", {