完善示例

This commit is contained in:
caizhitao 2020-06-23 17:09:30 +08:00
parent cc8c3b8bed
commit 987bb8f58b
2 changed files with 188 additions and 98 deletions

View File

@ -77,14 +77,14 @@
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{
"__id__": 130
},
{
"__id__": 131
},
{ {
"__id__": 132 "__id__": 132
},
{
"__id__": 133
},
{
"__id__": 134
} }
], ],
"_prefab": null, "_prefab": null,
@ -254,7 +254,7 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 129 "__id__": 131
} }
], ],
"_prefab": null, "_prefab": null,
@ -5164,7 +5164,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Examples", "_name": "ScrollView",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 5 "__id__": 5
@ -5172,30 +5172,15 @@
"_children": [ "_children": [
{ {
"__id__": 115 "__id__": 115
},
{
"__id__": 117
},
{
"__id__": 119
},
{
"__id__": 121
},
{
"__id__": 123
},
{
"__id__": 125
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 127 "__id__": 129
}, },
{ {
"__id__": 128 "__id__": 130
} }
], ],
"_prefab": null, "_prefab": null,
@ -5210,7 +5195,7 @@
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 384, "width": 384,
"height": 676.8 "height": 640
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@ -5244,6 +5229,87 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "2d/atMp8dG4L16Rl7WrAM5"
},
{
"__type__": "cc.Node",
"_name": "Examples",
"_objFlags": 0,
"_parent": {
"__id__": 114
},
"_children": [
{
"__id__": 116
},
{
"__id__": 118
},
{
"__id__": 120
},
{
"__id__": 122
},
{
"__id__": 124
},
{
"__id__": 126
}
],
"_active": true,
"_components": [
{
"__id__": 128
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 1238.8
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 1
},
"_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": "feymBChPxA1pr6+/rlPqey" "_id": "feymBChPxA1pr6+/rlPqey"
}, },
{ {
@ -5251,13 +5317,13 @@
"_name": "shark_1", "_name": "shark_1",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 114 "__id__": 115
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 116 "__id__": 117
} }
], ],
"_prefab": null, "_prefab": null,
@ -5284,7 +5350,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
-70.64999999999999, -82.64999999999999,
0, 0,
0, 0,
0, 0,
@ -5313,7 +5379,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 115 "__id__": 116
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
@ -5345,13 +5411,13 @@
"_name": "sushi_1", "_name": "sushi_1",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 114 "__id__": 115
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 118 "__id__": 119
} }
], ],
"_prefab": null, "_prefab": null,
@ -5378,7 +5444,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
-249.04999999999998, -261.04999999999995,
0, 0,
0, 0,
0, 0,
@ -5407,7 +5473,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 117 "__id__": 118
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
@ -5439,13 +5505,13 @@
"_name": "giraffe_1", "_name": "giraffe_1",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 114 "__id__": 115
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 120 "__id__": 121
} }
], ],
"_prefab": null, "_prefab": null,
@ -5472,7 +5538,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
-516.8, -528.8,
0, 0,
0, 0,
0, 0,
@ -5501,7 +5567,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 119 "__id__": 120
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
@ -5533,13 +5599,13 @@
"_name": "cocos_logo", "_name": "cocos_logo",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 114 "__id__": 115
}, },
"_children": [], "_children": [],
"_active": false, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 122 "__id__": 123
} }
], ],
"_prefab": null, "_prefab": null,
@ -5566,7 +5632,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
-312.29999999999995, -859.8,
0, 0,
0, 0,
0, 0,
@ -5595,7 +5661,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 121 "__id__": 122
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
@ -5627,13 +5693,13 @@
"_name": "ball_1", "_name": "ball_1",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 114 "__id__": 115
}, },
"_children": [], "_children": [],
"_active": false, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 124 "__id__": 125
} }
], ],
"_prefab": null, "_prefab": null,
@ -5660,7 +5726,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
-543.3, -1090.8,
0, 0,
0, 0,
0, 0,
@ -5689,7 +5755,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 123 "__id__": 124
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
@ -5721,13 +5787,13 @@
"_name": "BmFont", "_name": "BmFont",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 114 "__id__": 115
}, },
"_children": [], "_children": [],
"_active": false, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 126 "__id__": 127
} }
], ],
"_prefab": null, "_prefab": null,
@ -5754,7 +5820,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
-659.3, -1206.8,
0, 0,
0, 0,
0, 0,
@ -5783,7 +5849,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 125 "__id__": 126
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
@ -5812,45 +5878,18 @@
"_N$cacheMode": 0, "_N$cacheMode": 0,
"_id": "7cXLgoUJhDP7BPjr4yx+Ep" "_id": "7cXLgoUJhDP7BPjr4yx+Ep"
}, },
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 114
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 41,
"_left": 0.6,
"_right": 0,
"_top": 0,
"_bottom": 48,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": false,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 509,
"_originalHeight": 0,
"_id": "80mVZhmc1LHYCtsbpy1Jnu"
},
{ {
"__type__": "cc.Layout", "__type__": "cc.Layout",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 114 "__id__": 115
}, },
"_enabled": true, "_enabled": true,
"_layoutSize": { "_layoutSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 384, "width": 0,
"height": 676.8 "height": 1238.8
}, },
"_resize": 1, "_resize": 1,
"_N$layoutType": 2, "_N$layoutType": 2,
@ -5862,8 +5901,8 @@
"_N$startAxis": 0, "_N$startAxis": 0,
"_N$paddingLeft": 0, "_N$paddingLeft": 0,
"_N$paddingRight": 0, "_N$paddingRight": 0,
"_N$paddingTop": 0, "_N$paddingTop": 12,
"_N$paddingBottom": 0, "_N$paddingBottom": 12,
"_N$spacingX": 48, "_N$spacingX": 48,
"_N$spacingY": 36, "_N$spacingY": 36,
"_N$verticalDirection": 1, "_N$verticalDirection": 1,
@ -5871,6 +5910,57 @@
"_N$affectedByScale": true, "_N$affectedByScale": true,
"_id": "ff9z0nF9BGm5zFMuGhj1jt" "_id": "ff9z0nF9BGm5zFMuGhj1jt"
}, },
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 114
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0.6,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": false,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "66DhDtyM5DXI4OitKADVOI"
},
{
"__type__": "cc.ScrollView",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 114
},
"_enabled": true,
"horizontal": false,
"vertical": true,
"inertia": true,
"brake": 0.5,
"elastic": true,
"bounceDuration": 1,
"scrollEvents": [],
"cancelInnerEvents": true,
"_N$content": {
"__id__": 115
},
"content": {
"__id__": 115
},
"_id": "6afSoDGrxMdbMz9CZsHCeI"
},
{ {
"__type__": "68622NlRNJFN4QrXlFCQMe/", "__type__": "68622NlRNJFN4QrXlFCQMe/",
"_name": "", "_name": "",
@ -5898,16 +5988,6 @@
"_fitHeight": true, "_fitHeight": true,
"_id": "4bz2+ak99DBYVlSVIMFGN0" "_id": "4bz2+ak99DBYVlSVIMFGN0"
}, },
{
"__type__": "eebe5Fr5bhMO7IsowoLW/Yp",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_id": "1a7ypfDW1DQqGMHUC5Sf0L"
},
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
"_name": "", "_name": "",
@ -5934,5 +6014,15 @@
"_originalWidth": 0, "_originalWidth": 0,
"_originalHeight": 0, "_originalHeight": 0,
"_id": "314F24pJRBBZaYka0OCTsh" "_id": "314F24pJRBBZaYka0OCTsh"
},
{
"__type__": "eebe5Fr5bhMO7IsowoLW/Yp",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_id": "1a7ypfDW1DQqGMHUC5Sf0L"
} }
] ]

View File

@ -20,7 +20,7 @@ export default class GlowInnerEffectScene extends cc.Component {
private _glowThresholdSlider: cc.Slider = null; private _glowThresholdSlider: cc.Slider = null;
private _glowThresholdSliderLabel: cc.Label = null; private _glowThresholdSliderLabel: cc.Label = null;
private _examplesParentNode: cc.Node = null; private _scrollView: cc.ScrollView = null;
onLoad() { onLoad() {
this._redSlider = cc.find("Canvas/Content/Sliders/ColorRedSlider/Slider").getComponent(cc.Slider); this._redSlider = cc.find("Canvas/Content/Sliders/ColorRedSlider/Slider").getComponent(cc.Slider);
@ -41,7 +41,7 @@ export default class GlowInnerEffectScene extends cc.Component {
this._glowThresholdSlider = cc.find("Canvas/Content/Sliders/GlowThresholdSlider/Slider").getComponent(cc.Slider); this._glowThresholdSlider = cc.find("Canvas/Content/Sliders/GlowThresholdSlider/Slider").getComponent(cc.Slider);
this._glowThresholdSliderLabel = cc.find("Canvas/Content/Sliders/GlowThresholdSlider/ValueLabel").getComponent(cc.Label); this._glowThresholdSliderLabel = cc.find("Canvas/Content/Sliders/GlowThresholdSlider/ValueLabel").getComponent(cc.Label);
this._examplesParentNode = cc.find("Canvas/Content/Examples"); this._scrollView = cc.find("Canvas/Content/ScrollView").getComponent(cc.ScrollView);
} }
onEnable() { onEnable() {
@ -113,7 +113,7 @@ export default class GlowInnerEffectScene extends cc.Component {
*/ */
glowThreshold: number; glowThreshold: number;
}) { }) {
this._examplesParentNode.children.forEach((childNode) => { this._scrollView.content.children.forEach((childNode) => {
childNode.getComponents(cc.RenderComponent).forEach((renderComponent) => { childNode.getComponents(cc.RenderComponent).forEach((renderComponent) => {
let spriteFrameRect = (<cc.Sprite>renderComponent).spriteFrame.getRect(); let spriteFrameRect = (<cc.Sprite>renderComponent).spriteFrame.getRect();
let material: cc.Material = renderComponent.getMaterial(0); let material: cc.Material = renderComponent.getMaterial(0);