From 2ab560aa7ad10b4760af258f03750ddcfc89a625 Mon Sep 17 00:00:00 2001 From: caizhitao Date: Tue, 23 Jun 2020 18:01:31 +0800 Subject: [PATCH] bugfix --- assets/effects/sprite-glow-inner-v2.effect | 3 +- assets/materials/sprite-glow-inner-v2.mtl | 5 +- assets/scenes/GlowInnerV2EffectScene.fire | 216 ++++++++++----------- assets/scripts/GlowInnerV2EffectScene.ts | 26 ++- 4 files changed, 130 insertions(+), 120 deletions(-) diff --git a/assets/effects/sprite-glow-inner-v2.effect b/assets/effects/sprite-glow-inner-v2.effect index e9e5c6c..1737fa4 100644 --- a/assets/effects/sprite-glow-inner-v2.effect +++ b/assets/effects/sprite-glow-inner-v2.effect @@ -16,12 +16,11 @@ CCEffect %{ texture: { value: white } alphaThreshold: { value: 0.5 } # 自定义参数 - # 发光颜色 glowColor: { value: [1.0, 1.0, 0.0, 1.0], editor: { type: color, - tooltip: "发光颜色" + tooltip: "发光颜色(RGBA)" } } spriteWidth: { diff --git a/assets/materials/sprite-glow-inner-v2.mtl b/assets/materials/sprite-glow-inner-v2.mtl index dcc25e8..c7342d1 100644 --- a/assets/materials/sprite-glow-inner-v2.mtl +++ b/assets/materials/sprite-glow-inner-v2.mtl @@ -17,10 +17,11 @@ "glowColor": { "__type__": "cc.Color", "r": 255, - "g": 0, + "g": 255, "b": 0, "a": 255 - } + }, + "glowRange": 60 } } } diff --git a/assets/scenes/GlowInnerV2EffectScene.fire b/assets/scenes/GlowInnerV2EffectScene.fire index 2d43b7b..e28b290 100755 --- a/assets/scenes/GlowInnerV2EffectScene.fire +++ b/assets/scenes/GlowInnerV2EffectScene.fire @@ -5372,7 +5372,7 @@ "_is3DNode": false, "_groupIndex": 0, "groupIndex": 0, - "_id": "25JHa6EcNEBZ1hoesQM1Q4" + "_id": "19I84S9glPKYKXBymxRb7M" }, { "__type__": "cc.Sprite", @@ -5404,7 +5404,7 @@ "_fillRange": 0, "_isTrimmedMode": true, "_atlas": null, - "_id": "74+WCqN01NIbcSpr5gcxmE" + "_id": "63wzO33IhIzYLBDumqR/qS" }, { "__type__": "cc.Node", @@ -5500,102 +5500,6 @@ "_atlas": null, "_id": "4bH5hzKe9LsLQeXjLynIHQ" }, - { - "__type__": "cc.Node", - "_name": "BmFont", - "_objFlags": 0, - "_parent": { - "__id__": 115 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 121 - } - ], - "_prefab": null, - "_opacity": 255, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_contentSize": { - "__type__": "cc.Size", - "width": 167.5, - "height": 40 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_trs": { - "__type__": "TypedArray", - "ctor": "Float64Array", - "array": [ - 0, - -494, - 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": "e4XmdmRoVPxKoDxfbOgm42" - }, - { - "__type__": "cc.Label", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 120 - }, - "_enabled": true, - "_materials": [ - { - "__uuid__": "5e2baa0c-d8bf-493f-89f7-a11352092439" - } - ], - "_useOriginalSize": false, - "_string": "BM Font", - "_N$string": "BM Font", - "_fontSize": 40, - "_lineHeight": 40, - "_enableWrapText": true, - "_N$file": { - "__uuid__": "4c95de7e-8cca-47bf-a446-47b7594e0992" - }, - "_isSystemFontUsed": false, - "_spacingX": 0, - "_batchAsBitmap": false, - "_styleFlags": 0, - "_underlineHeight": 0, - "_N$horizontalAlign": 1, - "_N$verticalAlign": 1, - "_N$fontFamily": "Arial", - "_N$overflow": 0, - "_N$cacheMode": 0, - "_id": "7cXLgoUJhDP7BPjr4yx+Ep" - }, { "__type__": "cc.Node", "_name": "shark_1", @@ -5607,7 +5511,7 @@ "_active": true, "_components": [ { - "__id__": 123 + "__id__": 121 } ], "_prefab": null, @@ -5634,7 +5538,7 @@ "ctor": "Float64Array", "array": [ 0, - -620.65, + -544.65, 0, 0, 0, @@ -5663,7 +5567,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 122 + "__id__": 120 }, "_enabled": true, "_materials": [ @@ -5701,7 +5605,7 @@ "_active": true, "_components": [ { - "__id__": 125 + "__id__": 123 } ], "_prefab": null, @@ -5728,7 +5632,7 @@ "ctor": "Float64Array", "array": [ 0, - -799.05, + -723.05, 0, 0, 0, @@ -5757,7 +5661,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 124 + "__id__": 122 }, "_enabled": true, "_materials": [ @@ -5795,7 +5699,7 @@ "_active": true, "_components": [ { - "__id__": 127 + "__id__": 125 } ], "_prefab": null, @@ -5822,7 +5726,7 @@ "ctor": "Float64Array", "array": [ 0, - -1066.8, + -990.8, 0, 0, 0, @@ -5851,7 +5755,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 126 + "__id__": 124 }, "_enabled": true, "_materials": [ @@ -5878,6 +5782,102 @@ "_atlas": null, "_id": "1eCplTTO9BSJ6wePyWwtmu" }, + { + "__type__": "cc.Node", + "_name": "BmFont", + "_objFlags": 0, + "_parent": { + "__id__": 115 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 127 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 167.5, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -1206.8, + 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": "e4XmdmRoVPxKoDxfbOgm42" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 126 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "5e2baa0c-d8bf-493f-89f7-a11352092439" + } + ], + "_useOriginalSize": false, + "_string": "BM Font", + "_N$string": "BM Font", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": { + "__uuid__": "4c95de7e-8cca-47bf-a446-47b7594e0992" + }, + "_isSystemFontUsed": false, + "_spacingX": 0, + "_batchAsBitmap": false, + "_styleFlags": 0, + "_underlineHeight": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "7cXLgoUJhDP7BPjr4yx+Ep" + }, { "__type__": "cc.Layout", "_name": "", @@ -6023,6 +6023,6 @@ "__id__": 2 }, "_enabled": true, - "_id": "19XNHGZk1Gq7Fe5Qro9O/6" + "_id": "95Ls9T/ddFHotIEp1ouJiw" } ] \ No newline at end of file diff --git a/assets/scripts/GlowInnerV2EffectScene.ts b/assets/scripts/GlowInnerV2EffectScene.ts index 0bcc464..62fca4a 100644 --- a/assets/scripts/GlowInnerV2EffectScene.ts +++ b/assets/scripts/GlowInnerV2EffectScene.ts @@ -114,14 +114,24 @@ export default class GlowInnerV2EffectScene extends cc.Component { }) { this._scrollView.content.children.forEach((childNode) => { childNode.getComponents(cc.RenderComponent).forEach((renderComponent) => { - let spriteFrameRect = (renderComponent).spriteFrame.getRect(); - let material: cc.Material = renderComponent.getMaterial(0); - material.setProperty("spriteWidth", spriteFrameRect.width); - material.setProperty("spriteHeight", spriteFrameRect.height); - material.setProperty("glowRange", param.glowRange); - material.setProperty("glowColor", param.glowColor); - material.setProperty("glowThreshold", param.glowThreshold); - renderComponent.setMaterial(0, material); + if (renderComponent instanceof cc.Sprite) { + let spriteFrameRect = (renderComponent).spriteFrame.getRect(); + let material: cc.Material = renderComponent.getMaterial(0); + material.setProperty("spriteWidth", spriteFrameRect.width); + material.setProperty("spriteHeight", spriteFrameRect.height); + material.setProperty("glowRange", param.glowRange); + material.setProperty("glowColor", param.glowColor); + material.setProperty("glowThreshold", param.glowThreshold); + renderComponent.setMaterial(0, material); + } else { + let material: cc.Material = renderComponent.getMaterial(0); + material.setProperty("spriteWidth", childNode.width); + material.setProperty("spriteHeight", childNode.height); + material.setProperty("glowRange", param.glowRange); + material.setProperty("glowColor", param.glowColor); + material.setProperty("glowThreshold", param.glowThreshold); + renderComponent.setMaterial(0, material); + } }); }); }