Commit 5519a2c4 authored by asdf's avatar asdf

.

parent d9cfdf1f
const { ccclass, property } = cc._decorator;
@ccclass
export default class BaseUI extends cc.Component {
public nodeDict: { [name: string]: cc.Node } = {};
cc.Class({
extends: cc.Component,
onLoad() {
this.nodeDict = {};
this.linkWidget(this.node);
}
},
// 遍历节点树,获取重要节点
// 节点名字以$开头的节点为重要节点,放进nodeDict中,可以直接拿到,不用拖拽绑定
// $btn为按钮类型,放进nodeDict,并且绑定按钮点击事件
// $ui为ui节点,放进nodeDict,并且上面绑定了BaseUI脚本,所以不继续遍历该节点的子节点
// $btnUI为按钮类型ui节点,放进nodeDict,并且上面绑定了BaseUI脚本,所以不继续遍历该节点的子节点,并且绑定按钮点击事件
private linkWidget(node: cc.Node) {
linkWidget(node) {
let children = node.children;
for (let i = 0; i < children.length; i++) {
let nodeName = children[i].name;
......@@ -44,11 +44,11 @@ export default class BaseUI extends cc.Component {
this.linkWidget(children[i]);
}
}
}
},
public getNodeByName(name: string): cc.Node {
getNodeByName(name) {
return this.nodeDict[name];
}
},
buttonListener(button: cc.Button): void { }
}
\ No newline at end of file
buttonListener(button) { }
});
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "9b40e516-9ef7-4be9-9872-d8be39cb4fa6",
"uuid": "7af27a40-c9d2-4101-b894-8dff982f3985",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
const saveKey = "DataKey_Cocos_FT11";
import BaseUI from './BaseUI.js'
const BaseUI = require('BaseUI');
cc.Class({
extends: BaseUI,
......
{
"last-module-event-record-time": 1607312090200,
"last-module-event-record-time": 1607932083385,
"group-list": [
"default"
],
......@@ -28,6 +28,7 @@
"TiledMap",
"VideoPlayer",
"WebView",
"3D",
"3D Primitive",
"3D Physics/cannon.js",
"3D Physics/Builtin",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment