测试反馈修复

This commit is contained in:
2025-09-23 11:23:17 +08:00
parent e5c2c4f7ed
commit 568d360f49
7 changed files with 938 additions and 701 deletions
@@ -286,6 +286,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
let triggerId = girlData.getTriggerGrilPhotoId(this.categoryId, this.id);
if (triggerId == 0) return;
logger.log("Trigger pop up Image id:" + this.id + "--" + triggerId);
this.popUpImage.refresh(this.categoryId, this.id, triggerId);
@@ -8,6 +8,8 @@ import {
Size,
Vec3,
tween,
view,
screen,
} from "cc";
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
@@ -82,12 +84,30 @@ export class GirlDetailPanel extends li_BaseView {
@property(Node)
sendMsgText: Node;
private _nodeTab: any = {};
ImgVidSelect: Node;
ImgVidFakePos: Node;
// 跟随控制相关属性
private isFollowing: boolean = true; // 当前是否处于跟随状态
private lastFakePosPosition: Vec3 = new Vec3(); // 记录上次的位置
protected onEnable(): void {
this.refresh();
}
onLoadCT() {
super.onLoadCT();
Utils.parseNode(this.node, this._nodeTab);
this.ImgVidSelect = this._nodeTab.ImgVidSelect;
this.ImgVidFakePos = this._nodeTab.ImgVidFakePos;
// 初始化位置跟随
if (this.ImgVidFakePos) {
this.lastFakePosPosition = this.ImgVidFakePos.position.clone();
}
DetailImageItemPool.Instance.setTemplate(this.imgItemInst.node);
@@ -360,6 +380,75 @@ export class GirlDetailPanel extends li_BaseView {
super.onClose();
}
/**
* 检测节点是否在屏幕可见区域内
* @param node 要检测的节点
* @returns 是否在屏幕内
*/
private isNodeInScreen(node: Node): boolean {
if (!node) return false;
const uiTransform = node.getComponent(UITransform);
if (!uiTransform) return false;
// 获取屏幕尺寸
const screenSize = screen.windowSize;
const designResolution = view.getDesignResolutionSize();
// 获取节点的世界坐标
const worldPos = uiTransform.convertToWorldSpaceAR(Vec3.ZERO);
// 获取节点的尺寸
const nodeSize = uiTransform.contentSize;
// 计算节点的边界
const left = worldPos.x - nodeSize.width * uiTransform.anchorX;
const right = worldPos.x + nodeSize.width * (1 - uiTransform.anchorX);
const bottom = worldPos.y - nodeSize.height * uiTransform.anchorY;
const top = worldPos.y + nodeSize.height * (1 - uiTransform.anchorY);
// 检测是否完全在屏幕内
const isInScreen =
left >= 0 &&
right <= designResolution.width &&
bottom >= 0 &&
top <= designResolution.height - 160;
return isInScreen;
}
/**
* 实时更新ImgVidSelect跟随ImgVidFakePos的逻辑
*/
lateUpdate(dt: number) {
if (!this.ImgVidSelect || !this.ImgVidFakePos) {
return;
}
// 检测ImgVidFakePos是否在屏幕内
const isInScreen = this.isNodeInScreen(this.ImgVidFakePos);
if (isInScreen) {
// 在屏幕内,开始或继续跟随
if (!this.isFollowing) {
this.isFollowing = true;
logger.log("ImgVidSelect开始跟随ImgVidFakePos");
}
// 更新ImgVidSelect的位置到ImgVidFakePos的位置
this.ImgVidSelect.worldPosition =
this.ImgVidFakePos.worldPosition.clone();
this.lastFakePosPosition = this.ImgVidFakePos.worldPosition.clone();
} else {
// 超出屏幕,停止跟随
if (this.isFollowing) {
this.isFollowing = false;
logger.log("ImgVidSelect停止跟随ImgVidFakePos(超出屏幕)");
// ImgVidSelect保持在最后的跟随位置
}
}
}
/**
* 面板销毁时的清理工作
*/