Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Sbox_FT_11
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
Sbox_FT_11
Commits
5519a2c4
Commit
5519a2c4
authored
Dec 14, 2020
by
asdf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d9cfdf1f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
14 deletions
+15
-14
BaseUI.js
play/assets/tmpGame/script/BaseUI.js
+11
-11
BaseUI.js.meta
play/assets/tmpGame/script/BaseUI.js.meta
+1
-1
Scene.js
play/assets/tmpGame/script/Scene.js
+1
-1
project.json
play/settings/project.json
+2
-1
No files found.
play/assets/tmpGame/script/BaseUI.
t
s
→
play/assets/tmpGame/script/BaseUI.
j
s
View file @
5519a2c4
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
.
N
ode
)
{
linkWidget
(
n
ode
)
{
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
play/assets/tmpGame/script/BaseUI.
t
s.meta
→
play/assets/tmpGame/script/BaseUI.
j
s.meta
View file @
5519a2c4
{
"ver": "1.0.8",
"uuid": "
9b40e516-9ef7-4be9-9872-d8be39cb4fa6
",
"uuid": "
7af27a40-c9d2-4101-b894-8dff982f3985
",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
...
...
play/assets/tmpGame/script/Scene.js
View file @
5519a2c4
const
saveKey
=
"
DataKey_Cocos_FT11
"
;
import
BaseUI
from
'
./BaseUI.js
'
const
BaseUI
=
require
(
'
BaseUI
'
);
cc
.
Class
({
extends
:
BaseUI
,
...
...
play/settings/project.json
View file @
5519a2c4
{
"last-module-event-record-time"
:
1607
312090200
,
"last-module-event-record-time"
:
1607
932083385
,
"group-list"
:
[
"default"
],
...
...
@@ -28,6 +28,7 @@
"TiledMap"
,
"VideoPlayer"
,
"WebView"
,
"3D"
,
"3D Primitive"
,
"3D Physics/cannon.js"
,
"3D Physics/Builtin"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment