引导 基本完成

This commit is contained in:
2025-08-25 17:28:02 +08:00
parent 6a29821a7b
commit 6c95b3acc3
17 changed files with 1085 additions and 508 deletions

View File

@@ -1,4 +1,4 @@
import { _decorator, BlockInputEvents, Button, Label, Node, UITransform, Vec3 } from "cc";
import { _decorator, BlockInputEvents, Button, director, Label, Node, UITransform, Vec3 } 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 { IGuideStep, GuideStepType } from "../common/config/Guide";
@@ -33,6 +33,8 @@ export class GuideSetpComp extends CCComp {
private totalSteps: number = 0;
/** 目标节点 */
private _targetNode: Node | null = null;
/** 提示父节点 */
private _tipParent: Node | null = null;
private _showTip: boolean = false;
private _showHand: boolean = false;
private _callback: any = null;
@@ -104,7 +106,8 @@ export class GuideSetpComp extends CCComp {
}
/** 处理步骤信息 */
private handleStepInfo(data: any) {
const { step, stepIndex, totalSteps, targetNode,callbacks } = data;
const { step, stepIndex, totalSteps,callbacks } = data;
const targetNode=this.findTargetNode(step.targetPath);
this._noInput.enabled=step.noInput??false;
this._callback=callbacks;
if(targetNode){
@@ -116,10 +119,15 @@ export class GuideSetpComp extends CCComp {
this._showTip=true;
this._showHand=false;
}
if(step.tipParent){
this._tipParent=this.findTargetNode(step.tipParent);
}else{
this._tipParent=this._targetNode;
}
console.log("[GuideSetpComp] 处理步骤信息:", step);
// 显示步骤
this.showStep(step, stepIndex, totalSteps,targetNode);
this.showStep(step, stepIndex, totalSteps,targetNode,this._tipParent);
// 如果有手指位置,直接设置
// this.setHandPosition(this._targetNode);
@@ -137,18 +145,22 @@ export class GuideSetpComp extends CCComp {
}
/** 显示引导步骤 */
showStep(step: IGuideStep, stepIndex: number, totalSteps: number,targetNode: Node) {
showStep(step: IGuideStep, stepIndex: number, totalSteps: number,targetNode: Node,tipParent: Node) {
this.currentStep = step;
this.currentStepIndex = stepIndex;
this.totalSteps = totalSteps;
// 将handNode和tipNode从当前父节点移除
this.handNode.parent=this._targetNode;
this.tipNode.parent=this._targetNode;
// if(this._tipParent){
// this.tipNode.parent=this._tipParent;
// }else{
// this.tipNode.parent=this._targetNode;
// }
this.handNode.setPosition(this.currentStep?.handOffset?.x || 0, this.currentStep?.handOffset?.y || 0);
this.tipNode.setPosition(this.currentStep?.tipOffset?.x || 0, this.currentStep?.tipOffset?.y || 0);
// this.tipNode.setPosition(this.currentStep?.tipOffset?.x || 0, this.currentStep?.tipOffset?.y || 0);
// 设置setSiblingIndex最大
this.handNode.setSiblingIndex(this._targetNode.children.length - 1);
this.tipNode.setSiblingIndex(this._targetNode.children.length - 1);
// this.tipNode.setSiblingIndex(this._targetNode.children.length - 1);
// 更新UI内容
this.updateStepContent()
// 显示组件
@@ -185,7 +197,38 @@ export class GuideSetpComp extends CCComp {
}
}
/** 查找目标节点 */
private findTargetNode(path: string): Node | null {
console.log(`[GuideCon] 开始查找目标节点: ${path}`);
const pathParts = path.split('/');
let currentNode: any = director.getScene();
for (const part of pathParts) {
if (!currentNode || !currentNode.getChildByName) {
console.error(`[GuideCon] 节点 ${part} 不存在或没有getChildByName方法`);
break;
}
const childNode = currentNode.getChildByName(part);
if (!childNode) {
console.error(`[GuideCon] 找不到子节点: ${part}`);
console.log(`[GuideCon] 当前节点 ${currentNode.name} 的子节点:`, currentNode.children.map(c => c.name));
break;
}
currentNode = childNode;
console.log("[GuideCon] 当前节点:", currentNode)
}
if (currentNode) {
console.log(`[GuideCon] 目标节点查找成功:`, currentNode.position, currentNode.getWorldPosition());
return currentNode as Node;
} else {
console.error(`[GuideCon] 目标节点查找失败: ${path}`);
return null;
}
}
/** 跳过按钮点击事件 */
@@ -220,5 +263,6 @@ export class GuideSetpComp extends CCComp {
this.removeTouchListener();
this.tipNode.destroy();
this.handNode.destroy();
console.log("[GuideSetpComp] 监听onDestroy", this.node);
}
}