Commit 5519a2c4 authored by asdf's avatar asdf

.

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