[fix] Lobby 初始化清空 Child

This commit is contained in:
2022-05-07 10:54:33 +08:00
parent d771dd7593
commit 6bc14bc92a
11 changed files with 1278 additions and 1682 deletions

View File

@@ -91,10 +91,12 @@ export default class HoldButton extends cc.Component {
this._m_pressDeltaTime = 0;
if (this.OnInvoke != null) {
this.OnInvoke.forEach((eventHandler: cc.Component.EventHandler) => {
if (eventHandler.target === <any>"Callback" && eventHandler.component === "Callback" && eventHandler.handler) {
(<Function><unknown>eventHandler.handler)();
} else {
eventHandler.emit([this.node.getComponent(cc.Button)]);
if (eventHandler) {
if (eventHandler.target === <any>"Callback" && eventHandler.component === "Callback" && eventHandler.handler) {
(<Function><unknown>eventHandler.handler)();
} else {
eventHandler.emit([this.node.getComponent(cc.Button)]);
}
}
});
}

View File

@@ -39,6 +39,13 @@ declare namespace cc {
/**位置維持在原位 */
ExSetParent(parentObj: cc.Node): void;
ExSetGray(showGray: boolean): void;
/**
* 通过名称获取节点的子节点。
* @param name A name to find the child node.
* @example
* let child: cc.Node = this.node.Find("childname/childname");
*/
Find(name: string): cc.Node;
}
}
@@ -184,6 +191,27 @@ cc.Node.prototype.ExSetGray || Object.defineProperty(cc.Node.prototype, 'ExSetGr
// }
},
});
cc.Node.prototype.Find || Object.defineProperty(cc.Node.prototype, "Find", {
enumerable: false,
/**
* 通过名称获取节点的子节点。
* @param name A name to find the child node.
*/
value: function (name: string): any {
let names: string[] = name.split("/");
let node: cc.Node = this;
for (let i: number = 0; i < names.length; i++) {
const targetname: string = names[i];
let nodeName: string = node.name;
node = node.getChildByName(targetname);
if (!node) {
cc.error(`${nodeName} child hst not found ${targetname} in node`);
return null;
}
}
return node;
},
});
// cc.Node.prototype.SetWorldPosition = function (cocosWorldPos: cc.Vec2): void {
// // let cocosWorldPos = new cc.Vec2(unityWorldPos.x + 711, unityWorldPos.y + 400);
// this.setPosition(this.parent.convertToNodeSpaceAR(cocosWorldPos));