Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
unit_demo
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
unit_demo
Commits
8e467e99
Commit
8e467e99
authored
Sep 17, 2020
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 菜单控制组件完成
parent
eaa67fb7
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
866 additions
and
36 deletions
+866
-36
ButtonsNode.js
play/assets/resources/prefabs/ButtonsNode.js
+34
-25
ButtonsNode.prefab
play/assets/resources/prefabs/ButtonsNode.prefab
+112
-2
demo_01_showFireworks.fire
play/assets/tmpGame/scene/demo_01_showFireworks.fire
+662
-1
demo_01_showFireworks.js
play/assets/tmpGame/scene/demo_01_showFireworks.js
+38
-0
demo_01_showFireworks.js.meta
play/assets/tmpGame/scene/demo_01_showFireworks.js.meta
+9
-0
mainPage.js
play/assets/tmpGame/scene/mainPage.js
+11
-8
No files found.
play/assets/resources/prefabs/ButtonsNode.js
View file @
8e467e99
...
...
@@ -18,7 +18,6 @@ cc.Class({
},
start
()
{
this
.
initListeners
();
},
initListeners
()
{
...
...
@@ -26,44 +25,54 @@ cc.Class({
const
BtnPrevious
=
this
.
node
.
getChildByName
(
'
BtnPrevious
'
);
const
BtnBack
=
this
.
node
.
getChildByName
(
'
BtnBack
'
);
const
buttonsNode
=
cc
.
find
(
'
ButtonsNode
'
);
BtnNext
.
active
=
true
;
BtnPrevious
.
active
=
true
;
if
(
!
this
.
_dataList
[
this
.
_currentIdx
+
1
])
{
console
.
log
(
'
汪汪汪
'
)
BtnNext
.
active
=
false
;
}
BtnNext
.
on
(
'
click
'
,
()
=>
{
demoItem
=
this
.
_dataList
[
this
.
_currentIdx
+
1
];
cc
.
director
.
loadScene
(
demoItem
.
sceneName
,
()
=>
{
const
scene
=
cc
.
director
.
getScene
();
const
newButtonNode
=
cc
.
instantiate
(
buttonsNode
);
newButtonNode
.
parent
=
scene
;
newButtonNode
.
x
=
0
;
newButtonNode
.
y
=
0
;
newButtonNode
.
getComponent
(
'
ButtonsNode
'
).
setDataList
(
demoList
,
idx
);
});
});
if
(
!
this
.
_dataList
[
this
.
_currentIdx
-
1
])
{
console
.
log
(
'
喵喵喵
'
)
BtnPrevious
.
active
=
false
;
}
BtnPrevious
.
on
(
'
click
'
,
()
=>
{
demoItem
=
this
.
_dataList
[
this
.
_currentIdx
-
1
];
cc
.
director
.
loadScene
(
demoItem
.
sceneName
,
()
=>
{
const
scene
=
cc
.
director
.
getScene
();
const
newButtonNode
=
cc
.
instantiate
(
buttonsNode
);
newButtonNode
.
parent
=
scene
;
newButtonNode
.
x
=
0
;
newButtonNode
.
y
=
0
;
newButtonNode
.
getComponent
(
'
ButtonsNode
'
).
setDataList
(
demoList
,
idx
);
cc
.
resources
.
load
(
'
prefabs/ButtonsNode
'
,
cc
.
Prefab
,
(
err
,
ButtonsNode
)
=>
{
const
dataList
=
this
.
_dataList
;
const
currentIdx
=
this
.
_currentIdx
;
BtnNext
.
on
(
'
click
'
,
()
=>
{
demoItem
=
this
.
_dataList
[
this
.
_currentIdx
+
1
];
cc
.
director
.
loadScene
(
demoItem
.
sceneName
,
()
=>
{
const
newButtonNode
=
cc
.
instantiate
(
ButtonsNode
);
newButtonNode
.
parent
=
cc
.
find
(
'
Canvas
'
);
newButtonNode
.
x
=
0
;
newButtonNode
.
y
=
0
;
newButtonNode
.
getComponent
(
'
ButtonsNode
'
).
setDataList
(
dataList
,
currentIdx
+
1
);
});
});
BtnPrevious
.
on
(
'
click
'
,
()
=>
{
demoItem
=
this
.
_dataList
[
this
.
_currentIdx
-
1
];
cc
.
director
.
loadScene
(
demoItem
.
sceneName
,
()
=>
{
const
newButtonNode
=
cc
.
instantiate
(
ButtonsNode
);
newButtonNode
.
parent
=
cc
.
find
(
'
Canvas
'
);
newButtonNode
.
x
=
0
;
newButtonNode
.
y
=
0
;
newButtonNode
.
getComponent
(
'
ButtonsNode
'
).
setDataList
(
dataList
,
currentIdx
-
1
);
});
});
});
BtnBack
.
on
(
'
click
'
,
()
=>
{
cc
.
director
.
loadScene
(
'
mainPage
'
);
BtnBack
.
on
(
'
click
'
,
()
=>
{
cc
.
director
.
loadScene
(
'
mainPage
'
);
});
});
},
setDataList
(
dataList
,
currentIdx
)
{
this
.
_dataList
=
dataList
;
this
.
_currentIdx
=
currentIdx
;
this
.
initListeners
();
},
// update (dt) {},
...
...
play/assets/resources/prefabs/ButtonsNode.prefab
View file @
8e467e99
...
...
@@ -25,16 +25,19 @@
},
{
"__id__": 24
},
{
"__id__": 35
}
],
"_active": true,
"_components": [
{
"__id__": 3
5
"__id__": 3
8
}
],
"_prefab": {
"__id__": 3
6
"__id__": 3
9
},
"_opacity": 255,
"_color": {
...
...
@@ -1406,6 +1409,113 @@
"fileId": "aa1/O6kH1CT62jMktS6TUP",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "New Sprite(Splash)",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 36
}
],
"_prefab": {
"__id__": 37
},
"_opacity": 100,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 112,
"b": 244,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1280,
"height": 720
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 35
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "ffa620db-880d-4ed4-8dd1-00133559ac52"
},
"fileId": "e04yZ0G1dPgoekC5dZ6w45",
"sync": false
},
{
"__type__": "abb52OcegZE5rPyTByt2ykw",
"_name": "",
...
...
play/assets/tmpGame/scene/demo_01_showFireworks.fire
View file @
8e467e99
This diff is collapsed.
Click to expand it.
play/assets/tmpGame/scene/demo_01_showFireworks.js
0 → 100644
View file @
8e467e99
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc
.
Class
({
extends
:
cc
.
Component
,
properties
:
{
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start
()
{
},
// update (dt) {},
});
play/assets/tmpGame/scene/demo_01_showFireworks.js.meta
0 → 100644
View file @
8e467e99
{
"ver": "1.0.8",
"uuid": "a6c50b72-661b-43cf-bfae-419ac3306e3e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
play/assets/tmpGame/scene/mainPage.js
View file @
8e467e99
...
...
@@ -20,6 +20,9 @@ cc.Class({
const
demoList
=
[{
sceneName
:
'
demo_01_showFireworks
'
,
label
:
'
烟花效果
'
},
{
sceneName
:
'
demo_01_showFireworks
'
,
label
:
'
烟花效果
'
}];
demoList
.
forEach
((
demoItem
,
idx
)
=>
{
...
...
@@ -34,16 +37,16 @@ cc.Class({
button
.
x
=
(
width
/
widthLength
)
*
((
idx
%
widthLength
)
-
(
widthLength
-
1
)
/
2
);
button
.
y
=
300
-
Math
.
floor
(
idx
/
widthLength
)
*
50
;
const
buttonsNode
=
cc
.
find
(
'
ButtonsNode
'
);
button
.
on
(
'
click
'
,
()
=>
{
cc
.
director
.
loadScene
(
demoItem
.
sceneName
,
()
=>
{
const
scene
=
cc
.
director
.
getScene
();
const
newButtonNode
=
cc
.
instantiate
(
buttonsNode
);
newButtonNode
.
parent
=
scene
;
newButtonNode
.
x
=
0
;
newButtonNode
.
y
=
0
;
newButtonNode
.
getComponent
(
'
ButtonsNode
'
).
setDataList
(
demoList
,
idx
);
cc
.
resources
.
load
(
'
prefabs/ButtonsNode
'
,
cc
.
Prefab
,
function
(
err
,
ButtonsNode
)
{
const
newButtonNode
=
cc
.
instantiate
(
ButtonsNode
);
newButtonNode
.
getComponent
(
'
ButtonsNode
'
).
setDataList
(
demoList
,
idx
);
newButtonNode
.
parent
=
cc
.
find
(
'
Canvas
'
);
newButtonNode
.
x
=
0
;
newButtonNode
.
y
=
0
;
});
});
});
});
...
...
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